ClientScript.RegisterStartupScript problem

Discussion in 'ASP .Net' started by HockeyFan, Jul 20, 2007.

  1. HockeyFan

    HockeyFan Guest

    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?
     
    HockeyFan, Jul 20, 2007
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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?
    >
     
    George Ter-Saakov, Jul 20, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?c3Ryb3V0?=

    Handle RadioButtonList click event by Clientscript

    =?Utf-8?B?c3Ryb3V0?=, Oct 12, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    12,168
    Greg Burns
    Oct 13, 2004
  2. sck10
    Replies:
    7
    Views:
    7,457
    Steven Cheng[MSFT]
    Nov 17, 2005
  3. sck10
    Replies:
    3
    Views:
    7,603
  4. =?Utf-8?B?Qw==?=

    ClientScript.RegisterStartupScript

    =?Utf-8?B?Qw==?=, Aug 1, 2006, in forum: ASP .Net
    Replies:
    10
    Views:
    170,703
    zatch
    Nov 14, 2007
  5. Kaan Acar

    RegisterStartupScript problem

    Kaan Acar, Mar 17, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    154
    Greg Finzer
    Dec 23, 2005
Loading...

Share This Page