Solved

capture the events

Posted on 2004-04-14
16
486 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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!
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 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