Hello,
to my understanding the ASP.NET process works as follows:
1) Page_Init(): At this moment the user should allocate his controls, set their IDs and connect them to the page (Controls.Add() ).
2) ASP.NET is parsing the ViewState and the rest of the HTTP Request. It now synchronizes the controls that the user has allocated in Page_Init() according to their ID.
3) Page_Load(): At this point the user controls should be initialized according to the ViewState. Further loading may occur.
4) Event Handlers are called.
5) etc.
Now, if we consider that the event handlers are called at step 4) and that ASP.NET had already found the sender object (the first parameter of "void something_Click ( object sender, EventArgs e )") by comparing the user control IDs with the IDs inside ViewState, then the sender object should already be known at "Page_Load( )".
How can I retrieve the sender object in Page_Load()? If that's not directly possible, how can I retrieve its control ID?
4 14193 Frinavale 9,735
Recognized Expert Moderator Expert
hmm, no ideas?
Using ASP.NET with VB.NET server side code for my projects, my page load method is declared as such:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load, Me.Load
The sender object is passed into this method as a parameter.
Does this help?
What are you trying to do?
-Frinny
Using ASP.NET with VB.NET server side code for my projects, my page load method is declared as such:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load, Me.Load
The sender object is passed into this method as a parameter.
Does this help?
What are you trying to do?
-Frinny
The sender object that is passed as a parameter to Page_Load() is always the control itself (this). I'm trying to get the sender object of the event (say, if a button was clicked on my table, and if the table defines Page_Load(), i want sender to be the button, not the table).
I've managed to find a way to get to the ID of the sender control: - protected string EventSenderId
-
{
-
get
-
{
-
foreach( string s in Request.Form )
-
if( s.StartsWith( ID ) && s.EndsWith( ".x" ) )
-
return s.Substring( ID.Length + 1, s.Length - ID.Length - 3 );
-
-
return null;
-
}
-
}
This is a very, very ugly way that I would like to avoid ...
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mercy |
last post by:
Hi,
I'm a newbie. I was trying to figure out how to use the Session_start method? The reference books I'm reading say that a session STARTS when "session_start" is called. But ... in their sample code... I never see that explicitly called. Is it supposed to be called from the Global.asa file (still not sure what that is...)
Is "session_start" a server-side scripting thing? Or a client-side scripting thing?
I'd really appreciate a nice...
|
by: Christoph Boget |
last post by:
Please forgive my ignorance as I'm still new to developing w/C#
(and in windows in general). So if I use the wrong terms, please
bear with me.
I'm using VS.NET and defining the events have been really simple.
Just double-click on the event and the definition for that event (along
with the method) gets written. I see that the first argument that is
set up is "object sender" while the second argument varies with the
particular event. ...
|
by: Sin |
last post by:
Hello,
I'm currently toying around with using a VB.NET interface in a VC.NET
program and I've come across somewhat of a problem. I found a workaround but
I figure I must be a bit off cause it feels weird.
I have two projects. One is a simple VC console program. The other is a VB
Class Library project (DLL) in which there is a form (Form1) on which there
is a button (Button1) and a textbox (TextBox1). Both these controls are
public.
|
by: Erick |
last post by:
Hi,
Is there any way that I can know the object that does
fires or does postback to the page on the Page_Load event.
I tried to use the sender object that is defined as
parameter into this event.
Thanks for any help provied.
|
by: Carpe Diem |
last post by:
Hello I have an aspx page that loses Session("user") value after a few
minutes even after I set
<sessionState mode="InProc" cookieless="false" timeout="300"> in web.config
and wrote
function Session_Start() {
Session.Timeout = 3000;
}
in global.asax
| |
by: tshad |
last post by:
This is from my previous post, but a different issue.
I have the following Javascript routine that opens a popup page, but doesn't
seem to work if called from an asp.net button. It seems to work fine from a
link.
The button does bring up the popup window, but when I press the links on the
page, it doesn't return or close the window.
****************************************************************************
|
by: romy |
last post by:
Hello
dot.net winforms
How Do I make casting from the sender object to controls in the form that
called the sub ?
|
by: Alan LeHun |
last post by:
I want to attach a context menu to multiple textboxes but I don't know
how the extract the name of the textbox that is the subject of the
event.
I can't seem to do anything with "sender as system.object" other than
get its type.
Could someone tell me how to extract this info? I don't like the untidy,
inefficient and anti-OO coding of using a seperate context menu for each
textbox.
|
by: Rob |
last post by:
I see that MsgBox(sender.ToString()) will return a string that includes the
Text value of a button...
Is there a way to return only the Text value (i.e., some additional property
designate) ?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |