Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ClientScript.RegisterStartupScript problem

Reply
Thread Tools

ClientScript.RegisterStartupScript problem

 
 
HockeyFan
Guest
Posts: n/a
 
      07-20-2007
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?

 
Reply With Quote
 
 
 
 
George Ter-Saakov
Guest
Posts: n/a
 
      07-20-2007
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.





"HockeyFan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> 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?
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem problem problem :( Need Help Mike ASP General 2 05-11-2004 08:36 AM



Advertisments