Hi all,
Is it possible to use validators inside WebAsyncRefreshPanel ?
I used custom validator for dropdown list. It works fine without WebAsyncRefreshPanel. But, with WebAsyncRefreshPanel, it shows an error.
How to implement validators inside WebAsyncRefreshPanel?
Hi,
I tried a RequiredFieldValidator and following custom validator for list and it seemed to work without problems.
<igmisc:WebAsyncRefreshPanel ID="WARP1" runat="server"> <asp:Button ID="Button1" runat="server" Text="Button" /> <asp:DropDownList ID="DropDownList1" runat="server" Height="20px" Width="115px"> <asp:ListItem>One</asp:ListItem> <asp:ListItem>Two</asp:ListItem> <asp:ListItem>Three</asp:ListItem> </asp:DropDownList> <asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="validateList" ControlToValidate="DropDownList1" ErrorMessage="CustomValidator"></asp:CustomValidator></igmisc:WebAsyncRefreshPanel>
I copied you exact code into an empty page and ran it using 2008 vol 2 and it does seem to work for on the first go around, but after you click the button the first time, the validator quits working.
For example. When you open the page, the drop down says 'One' (which is invalid). If you click the button, the validator indicates the value is not valid. Now, change the dropdown to 'Two' and click the Button again. Nothing happens... that's because 'Two' is a valid number, so the validator is not displayed (so one might conclude). However, change the dropdown back to 'One' again and click the button... nothing!
On on my system, at least, there is a problem with validators and client side validation after the first async callback in the WebAsyncRefreshPanel
Hi Randy,
I tested those codes again and they seem to work for me. To test a postback, you may set break point in OnLoad, or do something like
protected void Page_Load(object sender, EventArgs e){ this.Button1.Text += "+";}
After 1st click on Button no postback happens and invalid-validator-message is displayed because value is One.
After change value to Two invalid-message disappears and 2nd click on Button, triggers postback (text on button gets extra +)
After change value to One invalid-message appears again and 3rd click on Button does nothing (text on button stays the same).