Solved

capture the events

Posted on 2004-04-14
16
481 Views
Last Modified: 2010-04-15
how can i capture an onclick button event on OnInit or the begining of Page_load?
0
Comment
Question by:alain123
  • 7
  • 4
  • 3
  • +1
16 Comments
 
LVL 1

Author Comment

by:alain123
ID: 10826873
a dynamic created button
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 10827305
What do you mean "capture onclick in OnInit"?
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 10827397
                 this.reportDetail1.Init += new System.EventHandler(this.yourroutine);
0
 
LVL 1

Author Comment

by:alain123
ID: 10827500
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..
0
 
LVL 1

Author Comment

by:alain123
ID: 10827514
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.
0
 
LVL 20

Accepted Solution

by:
TheAvenger earned 500 total points
ID: 10827538
You can check the IsPostBack property. Then at least you can know if "some" button caused a post back of the page. You can also review the Request values (Request[0], Request[1], etc. or by name) and see, somewhere the pressed button's ID should be mentioned (maybe it's Request["ButtonID"] != null)
0
 
LVL 4

Expert Comment

by:caner_elci
ID: 10827556
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..
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 10827569
caner_elci, I think we are talking about an ASP.NET application. There is no MouseDown event, neither global variables
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:caner_elci
ID: 10827613
Oh, sorry... forget my post then..
0
 
LVL 1

Author Comment

by:alain123
ID: 10827672
thanks caner =)  ..  avenger let me see if that works, brb
0
 
LVL 1

Author Comment

by:alain123
ID: 10827996
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
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 10828027
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.
0
 
LVL 1

Author Comment

by:alain123
ID: 10828100
thank you gregory, appreaciatte your help.
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 10828207
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.toLowerCase().indexOf("netscape") > -1) {
                  theform = document.forms["MainForm"];
            }
            else {
                  theform = document.MainForm;
            }
            theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
            theform.__EVENTARGUMENT.value = eventArgument;
            theform.submit();
      }
// -->
</script>

as you can see you can read another form field the rest of the time :)
0
 
LVL 1

Author Comment

by:alain123
ID: 10834728
thank you gregory, i'll look into your code!

alain

0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 10834759
in other words it will come as form __EVENTTARGET = ctl0:ctl1:NameGiven
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now