J
Jesper Lund Stocholm
I have problems with sending javascript to the client from a dynamically
loaded usercontrol.
I have a single page that dynamically loads controls into a table cell in
a HTML-table. For one of these controls I would like to add some
javascript to the page loading my control. The problem is only - nothing
happens. The code that loads my usercontrol from my ASPX-page is:
tdContent.Controls.Add(Page.LoadControl(contentControl));
Where "tdContent" is a table cell and the variable "contentControl" is
the physical path to my usercontrol's ASCX-file.
I would think that I could do it like this (from my ASCX-file):
protected override void OnInit(EventArgs e)
{
Page.ClientScript.RegisterStartupScript(
this.GetType(), "key", "alert('foo');", true);
base.OnInit(e);
}
Som alas nothing happens. I have a gut feeling that it is due to the fact
that the HTML of my ASPX-page has been created when I try to add to it
from my usercontrol, but I have found nowhere in the doc that could bring
me closer to a explanation.
Any of you guys have an idea of what to do?
loaded usercontrol.
I have a single page that dynamically loads controls into a table cell in
a HTML-table. For one of these controls I would like to add some
javascript to the page loading my control. The problem is only - nothing
happens. The code that loads my usercontrol from my ASPX-page is:
tdContent.Controls.Add(Page.LoadControl(contentControl));
Where "tdContent" is a table cell and the variable "contentControl" is
the physical path to my usercontrol's ASCX-file.
I would think that I could do it like this (from my ASCX-file):
protected override void OnInit(EventArgs e)
{
Page.ClientScript.RegisterStartupScript(
this.GetType(), "key", "alert('foo');", true);
base.OnInit(e);
}
Som alas nothing happens. I have a gut feeling that it is due to the fact
that the HTML of my ASPX-page has been created when I try to add to it
from my usercontrol, but I have found nowhere in the doc that could bring
me closer to a explanation.
Any of you guys have an idea of what to do?