Anyway to capture which control caused a postback.

A

Andrew Karcher

I have an aspx page which has a number of controls on it text box, button,
drop down list, etc. that cause a postback.

On my aspx page, I also have a placeholder control that loads a different
user control dynamcially based on the how the page is called.

The User Control uses a base class that inherits from UserControl and a
custom interface and adds some custom properties to each User Control. On
each user control there are also a number of controls, text boxes, drop down
lists, etc that cause a postback

What I would like to do is in the page load of my aspx page on Postback I
would like to determine whether or not the control that caused the postback
is on my aspx page or on the User Control. The reason I would like to do
this is so that I can set some of the custom properties on the User Control
so they are available to the User Control in it's Page_Load. Is that
possible or is there another way that I can accomplish this?

Thanks,
Andrew
 
A

Andrew Karcher

I understand that each control is going to have a Unique ID, but can you
tell what property of the Page object contains which control caused the
postback or which events that Page is going to fire after loading the page?
 
A

Alvin Bruney

ok, i see what you are asking now.
Pretend this is the itemdatabound event handler for a datagrid
DataGrid t = (DataGrid)sender;

string id = t.ID;
 
A

Andrew Karcher

Can I do that in the Page Load.

What I would like to do would be something like this.

Page pg = (Page)sender;

foreach (PostBackEvent evt in pg.PostBackEvents)
{
if evt = "txt.OnTextChanged";
{ do stuff ... }
}

Where Events is the collection of PostBack Events that are going to be
raised.
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top