Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

capture the events

Posted on 2004-04-14
16
Medium Priority
?
490 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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!
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

618 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