validating a webpage before first postback

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
 
I

intrader

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!
 
R

Raul Macias

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?
 
G

Guest

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?
 
R

Raul Macias

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.
 

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

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top