Click here to Skip to main content
15,885,278 members
Home / Discussions / C#
   

C#

 
GeneralRe: Accessing unmanaged class from C# Pin
Leif Simon Goodwin3-Apr-16 21:16
Leif Simon Goodwin3-Apr-16 21:16 
QuestionHow to select Windows explorer's 'Sort by' type programmatically Pin
srikrishnathanthri28-Mar-16 23:32
srikrishnathanthri28-Mar-16 23:32 
AnswerRe: How to select Windows explorer's 'Sort by' type programmatically Pin
Garth J Lancaster29-Mar-16 0:05
professionalGarth J Lancaster29-Mar-16 0:05 
GeneralRe: How to select Windows explorer's 'Sort by' type programmatically Pin
srikrishnathanthri29-Mar-16 0:14
srikrishnathanthri29-Mar-16 0:14 
QuestionWPF and Unmanaged Liberaries Pin
AmbiguousName28-Mar-16 21:16
AmbiguousName28-Mar-16 21:16 
QuestionRe: WPF and Unmanaged Liberaries Pin
Richard MacCutchan28-Mar-16 21:51
mveRichard MacCutchan28-Mar-16 21:51 
AnswerRe: WPF and Unmanaged Liberaries Pin
Pete O'Hanlon28-Mar-16 21:55
mvePete O'Hanlon28-Mar-16 21:55 
QuestionValidate form with Ajaxoptions and unobtrusive in partial view Pin
Member 1204569228-Mar-16 9:17
Member 1204569228-Mar-16 9:17 
I have the following View:
C#
<script>
    $(document).ready(function () {
        $('.profile_boxes').click(function () {
            var val = $(this).attr('id');

            $('.profile_boxes').css('background', '#fff');
            $('.profile_boxes').css('border', '1px solid #ededed');

            $("#" + val).css('background', '#f6f6f6');
            $("#" + val).css('border', '1px solid #f55');


            $.ajax({
                url: '@Url.Action("RenderProfilePartials", "NewProfile")',
                data: { 'profile': val },
                cache: false,
                type: "POST",
                dataType: "html",
                success: function (data, textStatus, XMLHttpRequest) {
                    console.log(val);
                    $('#profilePartials').html(data);
                },
                error: function (data, textStatus, XMLHttpRequest) {
                    console.log(data);
                }
            });
        });
    });
</script>
<div class="centering col-lg-6 logged_in_mainboxes">
    <h2>What are you?</h2>
    <div id="band" class="col-lg-4 profile_boxes">
        <h3>Band</h3>
    </div>
    <div id="musican" class="col-lg-4 profile_boxes">
        <h3>Musican</h3>
    </div>
    <div id="regular" class="col-lg-4 profile_boxes">
        <h3>Regular</h3>
    </div>

    @Html.ValidationSummary(false)

    <div id="profilePartials">

    </div>
</div>


When you click on either Band, Musician or Regular, I partial view Is renderd:

HTML
<div id="band_info" class="col-lg-9 profileDesc">
        <p>Maybe some information about the band profile here.....</p>
        @using (Ajax.BeginForm("RegisterBand", "NewProfile", new AjaxOptions() { HttpMethod = "Post" }))
        {
            @Html.ValidationSummary(true, "", new { @class = "text-danger" })
            <div class="form-horizontal">
                <div class="form-group">
                    Bandname
                    <div class="col-md-10">
                        @Html.EditorFor(x => x.Name, new { htmlAttributes = new { @class = "form-control" } })
                        @Html.ValidationMessageFor(x => x.Name, "", new { @class = "text-danger" })
                    </div>
                </div>

                <div class="form-group">
                    Coverpicture
                    <div class="col-md-10">
                        @Html.EditorFor(x => x.CoverPicture, new { htmlAttributes = new { @class = "form-control" } })
                        @Html.ValidationMessageFor(x => x.CoverPicture, "", new { @class = "text-danger" })
                    </div>
                </div>

                <div class="form-group">
                    Description
                    <div class="col-md-10">
                        @Html.EditorFor(x => x.Description, new { htmlAttributes = new { @class = "form-control" } })
                        @Html.ValidationMessageFor(x => x.Description, "", new { @class = "text-danger" })
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-md-offset-2 col-md-10">
                        <input type="submit" value="Spara" class="btn btn-success" />
                    </div>
                </div>
            </div>
        }
</div>


Now I want to validate this forms with Ajaxoptions and unobtrusive. But when I hit Submit, the page Is reloaded and the partial views returned back.

I want it not reload, I want to make the validation without the reload.

Here Is my controller:
C#
[HttpPost]
public ActionResult RegisterBand(BandProfileModel model)
{

    if (ModelState.IsValid == false)
    {
        return PartialView("_BandRegisterPartial", model);
    }


    return View("Index");
}


I have enabled unobtrusive in web.config and all that stuff.

Anyone who can help me?
AnswerRe: Validate form with Ajaxoptions and unobtrusive in partial view Pin
Richard MacCutchan28-Mar-16 21:50
mveRichard MacCutchan28-Mar-16 21:50 
QuestionUsing C#: Squares on Chessboard a Queen can not move to. Pin
Member 1235774728-Mar-16 8:59
Member 1235774728-Mar-16 8:59 
AnswerRe: Using C#: Squares on Chessboard a Queen can not move to. Pin
Sascha Lefèvre28-Mar-16 9:24
professionalSascha Lefèvre28-Mar-16 9:24 
GeneralRe: Using C#: Squares on Chessboard a Queen can not move to. Pin
Member 1235774728-Mar-16 9:54
Member 1235774728-Mar-16 9:54 
AnswerRe: Using C#: Squares on Chessboard a Queen can not move to. Pin
Ron Nicholson28-Mar-16 9:57
professionalRon Nicholson28-Mar-16 9:57 
GeneralRe: Using C#: Squares on Chessboard a Queen can not move to. Pin
Member 1235774728-Mar-16 11:51
Member 1235774728-Mar-16 11:51 
AnswerRe: Using C#: Squares on Chessboard a Queen can not move to. Pin
Patrice T28-Mar-16 10:50
mvePatrice T28-Mar-16 10:50 
GeneralRe: Using C#: Squares on Chessboard a Queen can not move to. Pin
Member 1235774728-Mar-16 12:07
Member 1235774728-Mar-16 12:07 
GeneralRe: Using C#: Squares on Chessboard a Queen can not move to. Pin
Patrice T28-Mar-16 12:13
mvePatrice T28-Mar-16 12:13 
GeneralRe: Using C#: Squares on Chessboard a Queen can not move to. Pin
Member 1235774728-Mar-16 13:34
Member 1235774728-Mar-16 13:34 
GeneralRe: Using C#: Squares on Chessboard a Queen can not move to. Pin
OriginalGriff28-Mar-16 20:30
mveOriginalGriff28-Mar-16 20:30 
GeneralRe: Using C#: Squares on Chessboard a Queen can not move to. Pin
Member 1235774730-Mar-16 3:03
Member 1235774730-Mar-16 3:03 
GeneralRe: Using C#: Squares on Chessboard a Queen can not move to. Pin
OriginalGriff30-Mar-16 3:13
mveOriginalGriff30-Mar-16 3:13 
GeneralRe: Using C#: Squares on Chessboard a Queen can not move to. Pin
harold aptroot28-Mar-16 22:57
harold aptroot28-Mar-16 22:57 
GeneralRe: Using C#: Squares on Chessboard a Queen can not move to. Pin
Member 1235774730-Mar-16 3:05
Member 1235774730-Mar-16 3:05 
QuestionSession inside webmethod Pin
Sandy Safwat28-Mar-16 5:35
Sandy Safwat28-Mar-16 5:35 
QuestionRe: Session inside webmethod Pin
ZurdoDev28-Mar-16 7:35
professionalZurdoDev28-Mar-16 7:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.