473,378 Members | 1,544 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

__doPostBack and arguments


Hi,

I am using the following code in the page class:

this.Button1.Attributes["onclick"] = this.Page.GetPostBackClientEvent(this,
"MyButton1");

When the Page_Load fires, the arguments ("e" variable) are always empty and
the sender is always the form itself. I need to figure out which control
caused the postback to occur, because I have some relate process.

Any help is appreciated. Thanks.
Mike
Nov 18 '05 #1
3 4931
The page load event will always fire, even for a post back.

The most common way i've seen it done is this

in page_load

you just put

if(!page.ispostback)
{
do stuff you want to happen only the first time the page loads
}

then put your code in the code behind the button or whatever
on the postback, the page load stuff gets skipped and then your
button_onclick code fires normally


"Mike" wrote:

Hi,

I am using the following code in the page class:

this.Button1.Attributes["onclick"] = this.Page.GetPostBackClientEvent(this,
"MyButton1");

When the Page_Load fires, the arguments ("e" variable) are always empty and
the sender is always the form itself. I need to figure out which control
caused the postback to occur, because I have some relate process.

Any help is appreciated. Thanks.
Mike

Nov 18 '05 #2
"Mike" <Mi**@discussions.microsoft.com> wrote in message news:<3D**********************************@microso ft.com>...
this.Button1.Attributes["onclick"] = this.Page.GetPostBackClientEvent(this,
"MyButton1");

When the Page_Load fires, the arguments ("e" variable) are always empty and
the sender is always the form itself. I need to figure out which control
caused the postback to occur, because I have some relate process.


I take it you have multiple buttons pointed at the same handler? If
sender & eventargs are failing you, you could skip the middle man and
inspect the __EVENTTARGET & __EVENTARGUMENT values directly.

Request["__EVENTTARGET"] should get you the ID that the button was
rendered to the page with.
Jason
http://www.expatsoftware.com/
Nov 18 '05 #3

Phantastic! I skipped the middle man and it works as you said :-)

I also found an alternative solution with a hidden field. Set the value of
the hidden field and then read it on the server side. But I like better your
solution.

Thanks.
Mike

"Jason Kester" wrote:
"Mike" <Mi**@discussions.microsoft.com> wrote in message news:<3D**********************************@microso ft.com>...
this.Button1.Attributes["onclick"] = this.Page.GetPostBackClientEvent(this,
"MyButton1");

When the Page_Load fires, the arguments ("e" variable) are always empty and
the sender is always the form itself. I need to figure out which control
caused the postback to occur, because I have some relate process.


I take it you have multiple buttons pointed at the same handler? If
sender & eventargs are failing you, you could skip the middle man and
inspect the __EVENTTARGET & __EVENTARGUMENT values directly.

Request["__EVENTTARGET"] should get you the ID that the button was
rendered to the page with.
Jason
http://www.expatsoftware.com/

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Frankieboy | last post by:
Where is __doPostBack-function defined? I've got an application which generates a different __doPostBack-function when the code is being run on the server compared to the one on my laptop. The...
1
by: paul reed | last post by:
Hello, I am having some weird behavior between two machines...one which is running the 1.1 framework and one which is running 1.0. After opening a child form from a parent...I update the...
3
by: E | last post by:
I have 2 aspx pages... neither of which do anything out of the ordinary. One of the pages automatically generates this block of code when viewed at the client:...
3
by: Nikhil Patel | last post by:
Hi all, I have developed a web page with a sortable DataGrid with Select button column in ASP.Net. It works fine in inernet explorer. The purpose of the web page is to display it in a third party...
1
by: Adrian | last post by:
I appear to be losing ViewState information when calling the __doPostBack function. I am attempting to use the showModalDialog to load a new web page which confirms that a user wishes to save a...
3
by: Marcelo | last post by:
Hello, I am trying to create a postback event, and it is working, just not calling the sub. I have a datagrid which has <asp:DataGrid id="Mensajes" ... <Columns> <asp:HyperLinkColumn ....
0
by: Steve Richter | last post by:
ok, I admit I dont know what I am doing ... When a user clicks on a <tr> in a <table> I want the page to be posted back to the server with info as to what row was clicked. <tr...
3
by: Steve Wonderful | last post by:
I checked the rendered html and found __doPostBack() function was not found in the html source. Is there a reason? How do I force it to be generated. The page seems to function properly for post...
6
by: GaryDean | last post by:
below is the html of two dropdownlists as they are rendered. The first was created with Postback = false and I added the onchange="myFunction('DropDownList1,'') in code. I made this look very...
1
by: Philip | last post by:
I am attempting to use the ASP.NET generated __doPostBack JavaScript function in my custom JavaScript and I can use it successfully but only after the web page is loaded and idle. I prefer to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.