powiązanie modelu formularza internetowego asp.net 4.5: obsługiwane sprawdzanie poprawności po stronie klienta?
Jestem wielkim fanem powiązania modelu webforms asp.net 4.5 za pomocą adnotacji danych.
ascx:
<asp:FormView ItemType="Contact" runat="server" DefaultMode="Edit"
SelectMethod="GetContact" UpdateMethod="SaveContact">
<EditItemTemplate>
<asp:ValidationSummary runat="server" ID="valSum" />
Firstname: <asp:TextBox runat="server" ID="txtFirstname" Text='<%#: BindItem.Firstname %>' />
Lastname: <asp:TextBox runat="server" ID="txtLastname" Text='<%#: BindItem.Lastname %>' />
Email: <asp:TextBox runat="server" ID="txtEmail" Text='<%#: BindItem.Email %>' />
<asp:Button ID="Button1" runat="server" Text="Save" CommandName="Update" />
</EditItemTemplate>
</asp:FormView>
.cs:
public void SaveContact(Contact viewModel)
{
if (!Page.ModelState.IsValid)
{
return;
}
}
public Contact GetContact()
{
return new Contact();
}
Model:
public class Contact
{
[Required]
[StringLength(10, ErrorMessage="{1} tis te lang")]
public string Firstname { get; set; }
[Required]
[StringLength(10)]
public string Lastname { get; set; }
[Required]
[EmailAddress]
public string Email { get; set; }
}
Pytanie:
Czy sprawdzanie poprawności po stronie klienta jest obsługiwane natychmiast po zainstalowaniu w formularzach internetowych, takich jak MVC? Lub powinniśmy polegać na bibliotekach innych firm (DAValidation). Czy jest możliwe przeniesienie wartości Html.EnableClientValidation () na formularze internetowe?
Pozdrowienia,
Bart