validating a webpage before first postback

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am creating a webform in ASP.NET using C#.

I have a drop down list control and 5 textbox controls.

Each textbox control has a required field validator assigned to it.

I have a save button on the form.

When I first load the form and immediately hit the save button the field
validators work automatically, but the save button click event which I haved
put a break point on in the code behind page never fires.

It will fire only after I have done my first drop down list change event
which causes a post back.

I want to be able to have my save button click event execute on click before
a first post back.

How do I circumnavigate this behavior?

thanks

Chris
 
Hi,

I am creating a webform in ASP.NET using C#.

I have a drop down list control and 5 textbox controls.

Each textbox control has a required field validator assigned to it.

I have a save button on the form.

When I first load the form and immediately hit the save button the field
validators work automatically, but the save button click event which I haved
put a break point on in the code behind page never fires.

It will fire only after I have done my first drop down list change event
which causes a post back.

I want to be able to have my save button click event execute on click before
a first post back.
How do I circumnavigate this behavior?
I ran into the problem when I forgot to set the OnClick attribute for
the button. This happens when you are translating from a VB.NET page to a
C# page.

Perhaps this help!
 
So what happens when you click the 'save' button before touching the
drop-down list? does it postback the page and just fires the page_load()
event? or not even that?
 
yes, the field validators do their job but the save click event does not occur.

i believe if i knew where to put the break pointer I could find out exactly
when the
field validator's fire.

either way: neither the page load event for the page is entered or the save
click event, its almost like it is client side script firing., maybe it is?
 
I would check if the events for those two objects (your page and the save
button) are hooked up correctly.
In design view, go to the properties window. Select your page object from
the drop-down list and switch to the events section. Then check if the load
event has something assigned to it. If there is nothing there, that's the
problem. Do the same for the save button.
 
Back
Top