AMAZING!!! You were right! I'm still not quite sure why this should be
as it is obvious from my situation that something is very wrong about this.
See, the same ascx is being loaded by a treeview to display various objects
represented by different ID's.
On the face of it, it looks like polymorphism is out the window and now I
have to manually create copies of the ascx under different names so I can
assign them the appropriate ID in the instantiation....unless there is a way
to communicate that to the ascx via the viewstate, querystring or some other
means.
What do you suggest?
To make this concrete, here is where things are now:
//ASCX
private void Page_Load(object sender, System.EventArgs e){
this.ID="MyControl1";
But it looks like this is what it should be:
//ASPX
private void TreeViewControl_SelectedIndexChange(object sender,
System.EventArgs e){
TreeNode n = TreeViewControl.GetNodeFromIndex(e.NewNode);
ViewState["ContentId"]=n.ID; //or some other node dependent variation
Content.Controls.Add(LoadControl(n.ID+".ascx"));
....
//ASCX
private void Page_Load(object sender, System.EventArgs e){
this.ID=ViewState["ContentId"];
That looks about right, right? The idea being that ID has to be assigned in
the ASCX Page_Load and that ViewState is the best means of communication.
"S. Justin Gengo" <sjgengo@aboutfortunate[no-spam].com> wrote in message
news:10*************@corp.supernews.com...
Dan,
The solution for this one isn't obvious.
Make certain that you're specifying your control's ID. That means do this
inside of the control's page load:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Me.ID = "MyControl1"
End Sub
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"kw" <el*****************@hotmail.com> wrote in message
news:eU*************@TK2MSFTNGP12.phx.gbl... My aspx dynamically loads an ascx into a placeholder. The ascx has an
event. When I click on the submit linkbutton in the ascx, the event
does not fire. But if I click it a second time, it fires.
I put in tracing, and the OnInit (which loads the event handler) is
executed on the initial load and also on the 2nd. It just makes no sense to me.
Any ideas?
Thanks a zillion!!
Dan