asp.net Web Form custom error messages for each element

允我心安 提交于 2021-02-05 09:57:05

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!