Identify wich button was pressed!

  • Thread starter Thread starter bredal Jensen
  • Start date Start date
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.
 
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?
 
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
 
If you use Request.Form["__EVENTTARGET"] and html buttons you can understand
on submit which control was causin the submit

Regards
Martin
 
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
 
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

Back
Top