Running jscript in initialization of ContentPlaceHolder

G

Guest

Hi - We need to be able to invoke a child (contentplaceholder) page from a
master page and have the child run some jscript code in the initialization
event to load data specific to that child. We can't seem to find a way to do
it. The page.load event seems to be limited to the master page. How can we
do this on the child page?

Thanks for any help.
 
M

Mark Rae

We need to be able to invoke a child (contentplaceholder) page from a
master page

MasterPages don't work like this - a MasterPage is nothing more than a
UserControl. You don't invoke the contentplaceholder from the MasterPage -
you open the page and it builds the MasterPage around itself...
 
G

Guest

So are you saying there is no way to run jscript on page initialization for
the contentplaceholder page?
 
M

Mark Rae

So are you saying there is no way to run jscript on page initialization
for
the contentplaceholder page?


Apologies - when you said you wanted to "invoke" the page, I thought that's
what you meant...

You can run JavaScript from the page initialisation method of the
contentpage just like any other page...

private void Page_Init(object sender, System.EventArgs e)
{
ClientScript.RegisterStartupScript(GetType(), "Page_Init", "alert('Hello
from the content page');", true);
}
 

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