aspx function

G

Guest

All,

I have a ASP.NET/C# webform that contains a ASPRegularExpressionValidator
and a ASPRequiredFieldValidator, the form contains many fields to be filled
in. I have a send button at the bottom of the page that calls a function
within the webform that checks to see if the page is valid. If it is not a
label next the send button appears informing the user but if the page is
valid I would like to call a function in my code behind class is this
possible and how ?

Thanks
Msuk
 
T

Travis Murray

The RegularExpressionValidator and the RequiredFieldValidator are both
client-side validation controls. Therefore, the form will not submit until
you page is valid. Any code you put in your code behind class will fire
once the page is valid and the form is submitted.

--
Travis Murray
MCSD, MCT
Artiem Consulting, Inc.
http://www.artiem.com
Learn ASP.Net In Jamaica in 2005!

Visit http://www.artiem.com/jamaica.aspx for more details.
 
G

Guest

You got it all wrong.

In the click event of the button, do something like this:

MyButton_Click(object sender, System.EventArgs e){
if(Page.IsValid){
// DO STUFF THERE IF THE PAGE IS VALID
}
}

You don't have to manually display the error messages; .Net validators will
automatically display them when the page renders.
 
G

Guest

Hi,

The click event in the code behind only fires once the page is valid, if I
move the click event to the actual aspx form I am not able to use all the
namespaces I need.

Is there no way to call a function in the code behind from the aspx form?

Thanks
Msuk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top