问题
I have created a web application - form, along with backend SQL insertions and queries.
Currently I am displaying all user error messages:-
<div style="padding: 1em;">
<asp:DataList ID="dtlERA_Errors" runat="server" Visible="false">
<ItemTemplate>
-
<asp:Label ID="Label4" runat="server" Text='<%#Eval("Description") %>'></asp:Label></ItemTemplate>
</asp:DataList>
</div>
this div is at the bottom of my aspx page and it lists all errors in order.
However my goal is to create custom error messages for each element, displayed next to the elements (say a textbox) with a * and then the custom error message. I have seen a lot of modern web forms apply this technique.
Is this ajax/jquery based.... Can anyone provide me with some literature or a name (library) that I should look into? I would appreciate this.
回答1:
You should read up on asp.net validation controls
http://msdn.microsoft.com/en-us/library/aa479013.aspx
回答2:
For jQuery, I recommend the jQuery Validation Plugin.
For ASP.NET AJAX, I recommend the ValidatorCallout.
来源:https://stackoverflow.com/questions/18086072/asp-net-web-form-custom-error-messages-for-each-element