RegisterStartupScript() and RegisterClientScriptBlock()

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

I've been reading the following link :

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html
/aspnet-injectclientsidesc.asp
That supposedly tells you how to use these: RegisterStartupScript() and
RegisterClientScriptBlock() to inject client side script into a server
control.
I'm new to ASP.NET and am hoping someone can help.
I'm trying to get this snippet: <script language="JavaScript1.2"
src="adds/menu/wm_menu.js" type="text/javascript"></script>
to run in my server control.
Here is the code for the control:

<%@ Control Language="VB" %>
<script runat="server">


</script>
<p align="center">
<table height="90" width="100%" align="center" bgcolor="dodgerblue">
<tbody>
<tr>
<td rowspan="3">
<p align="left">
<asp:Image id="logo" runat="server"
ImageUrl="images/logo_wm.gif" ImageAlign="Top"></asp:Image>
</p>
</td>
<td valign="center" align="left" width="50%" colspan="2"
height="50" border="0">
</td>
</tr><script language="JavaScript1.2" src="adds/menu/wm_menu.js"
type="text/javascript"></script> /////// here is where I would like it.
<tr>
<td valign="center" width="50%" colspan="2" height="40"
rowspan="2" border="0">
<p align="center">
<asp:AdRotator id="header" runat="server"
Width="360px" Height="40px"
AdvertisementFile="adds/headerads.xml"></asp:AdRotator>
</p>
</td>
</tr>
<tr>
</tr>
</tbody>
</table>
</p>

CAn anyone help me get this code RegisterStartupScript() and
RegisterClientScriptBlock() to work?

Where does the code go in my control and what is the correct syntax?
 
Hi,

You can use page_load event to take advantage of
RegisterClientScriptBlock.

this.RegisterClientScriptBlock("myScript","<script
language="JavaScript1.2"
src="adds/menu/wm_menu.js" type="text/javascript"></script>
");

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
 

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

Back
Top