First import the namespace System.Text which is needed for the StringBuilder. I make up the needed javascript by appending to the StringBuilder object sb. In the RegisterStartupScript method I call the ToString() method on sb to make it a string.
Grz, Kris.
Read my blog | Twitter Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
XIII
All-Star
182789 Points
23485 Posts
ASPInsiders
Moderator
MVP
Use Page.RegisterStartupScript
May 03, 2005 11:06 AM|LINK
<%@ Page Language="C#" %>
<%@ Import namespace="System.Text" %>
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script>");
sb.Append("window.open('http://msdn.microsoft.com', '', '');");
sb.Append("</scr");
sb.Append("ipt>");
Page.RegisterStartupScript("test", sb.ToString());
}
</script>
<html>
<head>
</head>
<body>
<form runat="server">
</form>
</body>
</html>
Explanation:
First import the namespace System.Text which is needed for the StringBuilder. I make up the needed javascript by appending to the StringBuilder object sb. In the RegisterStartupScript method I call the ToString() method on sb to make it a string.
Grz, Kris.
Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!