Created
April 28, 2011 14:34
-
-
Save troufster/946460 to your computer and use it in GitHub Desktop.
MVC3 Ajax Validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using (Html.BeginForm("Create", "MyModel", FormMethod.Post, new { id = "CreateForm" })) | |
{ | |
@Html.ValidationSummary(true) | |
<fieldset> | |
<legend>MyModel</legend> | |
<div class="editor-label"> | |
@Html.LabelFor(model => model.Property) | |
</div> | |
<div class="editor-field"> | |
@Html.EditorFor(model => model.Property) | |
@Html.ValidationMessageFor(model => model.Property) | |
</div> | |
</fieldset> | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#ajaxstuff').ajaxLink({ | |
data: {}, | |
success: function (data) { | |
$('#ajaxdiv').append(data); | |
$.validator.unobtrusive.parseDynamicContent('form'); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using(new MvcForm(ViewContext)) | |
{ | |
<div class="editor-label"> | |
@Html.LabelFor(model => model.Property) | |
</div> | |
<div class="editor-field"> | |
@Html.EditorFor(model => model.Property) | |
@Html.ValidationMessageFor(model => model.Property) | |
</div> | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input class="text-box single-line" | |
data-val="true" | |
data-val-required="This field is required!" | |
id="Property" | |
name="Property" | |
type="text" | |
value="" | |
/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment