[ASP.NET] How to add javascript between two specific tag?

  • Thread starter Thread starter tranky
  • Start date Start date
T

tranky

Hi asp.net programmers,i've a question for you!

How to add javascript between two specific tag?
( for example div tag )

This javascript i must add in the page is a control, and i must
insert it beetween two div tag.

If use this.Page.ClientScript.RegisterClientScriptBlock,
the control is added in the head of the page, instead, if i use
this.Page.ClientScript.RegisterStartupScript the control is added in the
footer of the page.

In what way i can resolve this issue?

thanx
 
the final result should be this:

<body>

ecc...
ecc...

<div id="thisid">
<script ....>
// HERE THE JAVASCRIPT
</script>

</div>

ecc...
ecc...

</body>
 
IN THEPAGE:

<div id="scriptdiv">
<asp:PlaceHolder id="PlaceHolder1" runat="server"></asp:PlaceHolder>
</div>



IN THE CODEBEHIND:


string scr=@"<script>alert('yo!');</script>";
HtmlGenericControl gc = new HtmlGenericControl();
gc.InnerHtml=scr;
this.PlaceHolder1.Controls.Add(gc);


-- Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
 
Back
Top