I have a text box, webimagebutton on the form. textbox has a required field validator attached to it.
When i click on the webimagebutton, i have a method on the server which clears the value of the text box.
when i enter some value in the text box and reach to webimagebutton using tab and press space bar or Enter key, postback happens and the text box is cleared. this is expected. but the required field validator is showing error message. This is not correct. Can some one help on this? Thanks in advance.
Hi,
I tried following and could not reproduce difference between mouse-click and space/enter key-press. After I entered a text and submited (by any option), text was cleared and no validator message was displayed.
protected void WebImageButton1_Click(object sender, ButtonEventArgs e){ this.TextBox1.Text = "";}
<igtxt:WebImageButton ID="WebImageButton1" runat="server" onclick="WebImageButton1_Click"></igtxt:WebImageButton><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
Sorry if I'm not clear to you. When the postback happens i expect to see a empty textbox. But when submit the form by clicking space bar or Enter key, The textbox is cleared, but the required fields validator is displaying error message.
This is not the behaviour when i try to submit the form using mouse click. The textbox is cleared and the required field validator is not showing the error message. For me, this is correct behaviour and I expect the same behaviour when i submit the form by pressing the space bar or Enter key.
Unless I am not understanding something this sounds like its working correctly to me. What behavior are you wanting to happen. Lets look at it that way and see if that makes it any clearer.
its a asp:RequiredFieldValidator
What type of validatorare you using?