alain123
asked on
capture the events
how can i capture an onclick button event on OnInit or the begining of Page_load?
What do you mean "capture onclick in OnInit"?
this.reportDetail1.Init += new System.EventHandler(this.y ourroutine );
ASKER
I mean when I enter OnInit, to find out if Button1 has been clicked or not ...
gregor, i'm alerady doing that, but "yourroutine" will be the last event exceuted after OnInit and Page_load ..
I want to find out if the button was clicked at the begining of the flow..
gregor, i'm alerady doing that, but "yourroutine" will be the last event exceuted after OnInit and Page_load ..
I want to find out if the button was clicked at the begining of the flow..
ASKER
I create the link buttons dynamically and assign the
onClick handler, however I noticed that the Page_Load event is processed
first so I never get a chance to find out what linkbutton was clicked
until it is too late.
onClick handler, however I noticed that the Page_Load event is processed
first so I never get a chance to find out what linkbutton was clicked
until it is too late.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I don't know why do you need this, but try this:
Add an event handler to Button's MouseDown event.. and in MouseDown event, set a global boolean variable something like IsButtonPressed to true.. so you will be able to check it in OnInit event or whereever you want..
Add an event handler to Button's MouseDown event.. and in MouseDown event, set a global boolean variable something like IsButtonPressed to true.. so you will be able to check it in OnInit event or whereever you want..
caner_elci, I think we are talking about an ASP.NET application. There is no MouseDown event, neither global variables
Oh, sorry... forget my post then..
ASKER
thanks caner =) .. avenger let me see if that works, brb
ASKER
ok avenger, that was right .. if(Request["BackButton"] != null) works.. at least it has the name of the button when i do Request["BackButton"] on the imm window... thanks..
alain
alain
So sorry for the incomplete response but I was trying to guess at what you wanted since it was far from apparent in the wording of your question. The answer that it will be set on the Request object is correct though.
ASKER
thank you gregory, appreaciatte your help.
I will however add that this methodology does not work on ALL events ...
the following is the code is created for other events
<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName. toLowerCas e().indexO f("netscap e") > -1) {
theform = document.forms["MainForm"] ;
}
else {
theform = document.MainForm;
}
theform.__EVENTTARGET.valu e = eventTarget.split("$").joi n(":");
theform.__EVENTARGUMENT.va lue = eventArgument;
theform.submit();
}
// -->
</script>
as you can see you can read another form field the rest of the time :)
the following is the code is created for other events
<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.
theform = document.forms["MainForm"]
}
else {
theform = document.MainForm;
}
theform.__EVENTTARGET.valu
theform.__EVENTARGUMENT.va
theform.submit();
}
// -->
</script>
as you can see you can read another form field the rest of the time :)
ASKER
thank you gregory, i'll look into your code!
alain
alain
in other words it will come as form __EVENTTARGET = ctl0:ctl1:NameGiven
ASKER