ClientScript.RegisterStartupScript problem

H

HockeyFan

My function to get an alert box on the page isn't working.
Instead it puts in the bottom section of the page:
<script type="text/javascript">
<!--
This is a test// -->
</script>


The function is:
public static void MessageAlert_Create(ref System.Web.UI.Page
thePage,
Type thisType,
string strMessage,
string strKey)
{
System.Web.UI.ClientScriptManager ClientScript =
thePage.ClientScript;
string strScript = "alert('" + strMessage + "');";
if (!ClientScript.IsStartupScriptRegistered(thisType,
strKey))
{
ClientScript.RegisterStartupScript(thisType, strKey,
strMessage, true);
}
}

and I call this function as follows:
System.Web.UI.Page pg = this;
Bus.UtilStatic.MessageAlert_Create(ref pg,
this.GetType(), "This is a test", "Tester");


any ideas how to get the alert box to show up?
 
G

George Ter-Saakov

Well change
ClientScript.RegisterStartupScript(thisType, strKey, strMessage, true);

to
ClientScript.RegisterStartupScript(thisType, strKey, strScript , true);

notice the difference.
strScript instead of strMessage in your code.

George.
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top