andrewmilner
asked on
asp.net Form Validation i stopping OnClick event functioning
Okay so I had this function working fine which basically takes the postcode then looks up the address from code behind and then populates some other text boxes.
But now I have added the validation checks everytime I click the button to fire the onclick event the validation is fired and the onclick function isnt called.
Can you help?
But now I have added the validation checks everytime I click the button to fire the onclick event the validation is fired and the onclick function isnt called.
Can you help?
<asp:TextBox CausesValidation="false" CssClass="GlobalFormTextBox" ID="PostCodeTextBox" runat="server" Text='<%# Bind ("Postcode") %>'></asp:TextBox>
<asp:RequiredFieldValidator runat="server"
id="reqPostCode" ControlToValidate="PostCodeTextBox"
ErrorMessage = "PostCode" Text="*"
display="Dynamic" />
<asp:ImageButton ID="CheckPostCode" runat="server" OnClick="CheckPostCodeButton_Click" ImageUrl="~/images/PostCodeLookupIcon.gif" AlternateText="Find Address" />
protected void CheckPostCodeButton_Click(object sender, EventArgs e)
{
///some code in here
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Is there a Validation Error, indicating that the textbox is empty? If the textbox is empty, the OnClick won't fire, as the validation is checked first before even posting back.
ASKER
Nice one. Didnt think to add it to the button only the text box.
Many Thanks.
Many Thanks.