Identify wich button was pressed!

B

bredal Jensen

Hello,

I have a web form with three buttons among other things.
I need to know wich one of my buttons was pressed .
The problem is that i want my page to be valid before any of the
buttons "click" routines can do some processing , meaning that they have the
"Causevalidation" property set to true.

The validation routines depends upon which of the buttons was pressed.
How can i identify them in my validation routine?

Thanks in advance.
 
J

John Saunders

bredal Jensen said:
Hello,

I have a web form with three buttons among other things.
I need to know wich one of my buttons was pressed .
The problem is that i want my page to be valid before any of the
buttons "click" routines can do some processing , meaning that they have the
"Causevalidation" property set to true.

The validation routines depends upon which of the buttons was pressed.
How can i identify them in my validation routine?

Why not simply check Page.IsValid in the click routines before doing the
processing?
 
M

MattC

Wire up each of the buttons to the same event handler. When you get in
there the button that was clicked would have passed itself through the
postback. Getting the objects UniqueID will give you the Id of the button
that was clicked. Alternatively wireup a handler for each button and have
then all call your validation method.

MattC
 
M

Martin Marinov

If you use Request.Form["__EVENTTARGET"] and html buttons you can understand
on submit which control was causin the submit

Regards
Martin
 
B

bredal Jensen

That was brillant , thank you a lot !

MattC said:
Wire up each of the buttons to the same event handler. When you get in
there the button that was clicked would have passed itself through the
postback. Getting the objects UniqueID will give you the Id of the button
that was clicked. Alternatively wireup a handler for each button and have
then all call your validation method.

MattC
 
B

bredal Jensen

That does not solve my problem as i explained earlier.

I need to do validation before any processing in my "click routine" .
The problem is that Validation depends upon which button was clicked.

I hope you understands the problem.

Check out "MattC" reply , the problem can be solved by delegates
as he suggested....
Many Thanks
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top