Is it possible to use ASP.NET validation controls when I need to modify HTML when validation fails? -
Assume that I have the following HTML for the text box on the ASP.NET page:
< Code> & lt; Div class = "myClass" & gt; & Lt; ASP: Text Box ID = "Textile Textbox" Run = "Server" & gt; & Lt; / Asp: text box & gt; & Lt; / Div & gt;On this page it is easy to add a required field vendor.
& lt; Asp: RequiredFieldValidator id = "valMyTextBox" runat = "server" ControlToValidate = "txtMyTextBox" error message = "My text box is required" & gt; & Lt; / Asp: RequiredFieldValidator & gt;
But I need to modify a little bit of HTML if this text box validation fails. I have to add a CSS class to DIV. So if the user leaves this field then I need to look at HTML like this:
Is this possible? I can not understand that if there is any special way, then it is the only way to write code behind the fire, if this particular validator fails in validity or some things, I know that I can write that code Is not valid when it runs. But I just want to run this code when this validation is invalid. Hope this makes sense.
blank
OK I think this may help though Not sure if this is the exact way to do this
& lt; Div class = & lt;% Response.Write (validateTextBox ())% & gt; & Gt;
The task that will be on the server that you want to change the name of the class based on the text box
Comments
Post a Comment