Solved

capture the events

Posted on 2004-04-14
16
480 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 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

19 Experts available now in Live!

Get 1:1 Help Now