does page_load know

G

Guest

hey all,
does server-side page_load what button was pressed on a postback?

thanks,
rodchar
 
M

Mick Walker

rodchar said:
hey all,
does server-side page_load what button was pressed on a postback?

thanks,
rodchar
Not directly no. But its simple enough to set a Session variable so that
it will know.
 
P

Paul Hadfield

How would that help the OP though - Page_Load event fires before OnClick
event (which I would guess is where you would set the session value).
 
M

Mark Rae [MVP]

does server-side page_load [know] what button was pressed on a postback?

Yes - Request.Form["__EVENTTARGET"]

However, it has no need to know this...
 
G

Guest

Here's the reason i ask:

i have an UpdatePanel that contains a div which contains my web user control
called CalendarHelper.ascx. The user control consists of a textbox, calendar
image button, and calendar to help with date entry. I can load this user
control dynamically but whenever i click the calendar icon to make the
calendar appear the webcontrol just disappears on postback/async callback.

This is the only code i have and thought i would need:

protected void BtnEdit_Click(object sender, EventArgs e)
{
CalendarHelper cal1 = new CalendarHelper();
cal1 = (CalendarHelper)cal1.LoadControl("CalendarHelper.ascx");

divmain.Controls.Add(cal1);
}

p.s. i know there is an easier way to do this but i have to work with the
user control that i've been given.

Mark Rae said:
does server-side page_load [know] what button was pressed on a postback?

Yes - Request.Form["__EVENTTARGET"]

However, it has no need to know this...
 
M

Mark Rae [MVP]

i have an UpdatePanel that contains a div which contains my web user
control
called CalendarHelper.ascx. The user control consists of a textbox,
calendar
image button, and calendar to help with date entry. I can load this user
control dynamically but whenever i click the calendar icon to make the
calendar appear the webcontrol just disappears on postback/async callback.

What code is behind the calendar icon?
 
L

Lloyd Sheen

rodchar said:
Here's the reason i ask:

i have an UpdatePanel that contains a div which contains my web user
control
called CalendarHelper.ascx. The user control consists of a textbox,
calendar
image button, and calendar to help with date entry. I can load this user
control dynamically but whenever i click the calendar icon to make the
calendar appear the webcontrol just disappears on postback/async callback.

This is the only code i have and thought i would need:

protected void BtnEdit_Click(object sender, EventArgs e)
{
CalendarHelper cal1 = new CalendarHelper();
cal1 = (CalendarHelper)cal1.LoadControl("CalendarHelper.ascx");

divmain.Controls.Add(cal1);
}

p.s. i know there is an easier way to do this but i have to work with the
user control that i've been given.

Mark Rae said:
does server-side page_load [know] what button was pressed on a
postback?

Yes - Request.Form["__EVENTTARGET"]

However, it has no need to know this...

You need to reload the ascx in the page init event.

LS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top