Ok, another day, another problem!
I did create a few usercontrols which work together quite nicely. And after I wrapped an updatepanel around them, the ajax seems to work just fine.
However, once a validator inside the panel gets triggered the whole page freezes and it looks like javascript isn’t working anymore. I googled (cause bing just sucks) the problem and found very less about this problem, so when I finally found a solution I decided to share it with all of you having the same problem.
This is the problem:
When a validator is loaded on the page it creates a bit of javascript to support the clientside validation. When you place a validator inside an usercontrol that isn´t visible by default, and this usercontrol is in an updatepanel, it does not create that javascript properly.
This is the solution:
Outside the updatepanel, I did above, create a dummy validator with a dummy textbox using a dummy validationgroup like so:
<%--dummy validator to make ajax validation possible--%> <asp:RequiredFieldValidator runat="server" CssClass="hidden" ControlToValidate="dummyTextBox" ValidationGroup="dummy"></asp:RequiredFieldValidator> <asp:TextBox runat="server" ID="dummyTextBox" CssClass="hidden"></asp:TextBox>
The CssClass “hidden” corresponds with the following CSS:
<style> .hidden { display: none; } </style>
As you already might understand, the dummy validator now creates the proper javascript that the other ‘real’ validators can use.
Hope this also works for you. Also if you found another, maybe neater solution, please inform me…
Brilliant! Thanks so much!!
Holy crap dude I’ve spent several days on this problem. Your fix worked perfectly! Thank you!!!
Pfff jesus I’ve spent half day on this crap… Thanks man!
See i’m using three panels like pnl1,pnl2,pnl3.
In this i’ve requiredfieldvalidator for pnl1. But i need to enter the data for all three panels. Then i keep cursor in pnl3 and i presses save button ,here in this situation validation is not happening. Plz any one help me
I need a little more info than this to say something about it. Can you provide the error details and the executing code?
Many thanks, you solved my problem!
You saved my Day………………. Thanks
Thank you ever so much this has been driving me mad