Re: Problem with Response.Write("<script>alert('" + errorMessage + "')

Discussion in 'ASP .Net' started by William F. Robertson, Jr., Aug 13, 2004.

  1. What does the "View Source" look like when the page hits your browser?

    I did notice you don't have a language defined for your script tag, and you
    are missing your semi colon on your statement.

    bill

    "Vinny Vinn" <> wrote in message
    news:...
    > I an developing in C# when i call the following script
    > Response.Write("<script>alert('Entry is required')</script>");
    > the alert box is displayed
    >
    > however when the error messge is added in as a varible, no alert box is
    > displayed
    > and i recieve no runtine error,
    >
    > string errorMessage = "Entry is required";
    > Response.Write("<script>alert('" + errorMessage + "')</script>");
    >
    > Vinny
    >
    > it just seems as the code is not excuting.Why??
    >
    > Vinny
    >
    William F. Robertson, Jr., Aug 13, 2004
    #1
    1. Advertising

  2. Re: Problem with Response.Write("<script>alert('" + errorMessage +

    Willam,
    Thank you for your response.
    The language is defined in the header of the html file (as shown
    below).However you mentioned that i am missing a semi colon in my
    statement,where?
    <HEAD>
    <title>BasicInformation</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema"
    content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>

    "William F. Robertson, Jr." wrote:

    > What does the "View Source" look like when the page hits your browser?
    >
    > I did notice you don't have a language defined for your script tag, and you
    > are missing your semi colon on your statement.
    >
    > bill
    >
    > "Vinny Vinn" <> wrote in message
    > news:...
    > > I an developing in C# when i call the following script
    > > Response.Write("<script>alert('Entry is required')</script>");
    > > the alert box is displayed
    > >
    > > however when the error messge is added in as a varible, no alert box is
    > > displayed
    > > and i recieve no runtine error,
    > >
    > > string errorMessage = "Entry is required";
    > > Response.Write("<script>alert('" + errorMessage + "')</script>");
    > >
    > > Vinny
    > >
    > > it just seems as the code is not excuting.Why??
    > >
    > > Vinny
    > >

    >
    >
    >
    =?Utf-8?B?VmlubnkgVmlubg==?=, Aug 13, 2004
    #2
    1. Advertising

  3. Re: Problem with Response.Write("<script>alert('" + errorMessage +

    By using Response.Write (instead of Page.RegisterStartUpScript() ), it will
    write out the <script> tags before the <HEAD> tags gets sent to the browser.
    The browser will try to process it before it knows exactly what to do with
    it. I not saying this is you problem, just something I would suggest
    fixing.

    The semi-colon is missing at the end of your alert statement.

    Response.Write( "<script
    language=\"javascript\">\nalert('message');\n</script>\n" );

    If this still doesn't help, post a snippet of your "View Source" that is
    working correctly and is not.

    HTH,

    bill

    "Vinny Vinn" <> wrote in message
    news:...
    > Willam,
    > Thank you for your response.
    > The language is defined in the header of the html file (as shown
    > below).However you mentioned that i am missing a semi colon in my
    > statement,where?
    > <HEAD>
    > <title>BasicInformation</title>
    > <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    > <meta name="CODE_LANGUAGE" Content="C#">
    > <meta name="vs_defaultClientScript" content="JavaScript">
    > <meta name="vs_targetSchema"
    > content="http://schemas.microsoft.com/intellisense/ie5">
    > </HEAD>
    >
    > "William F. Robertson, Jr." wrote:
    >
    > > What does the "View Source" look like when the page hits your browser?
    > >
    > > I did notice you don't have a language defined for your script tag, and

    you
    > > are missing your semi colon on your statement.
    > >
    > > bill
    > >
    > > "Vinny Vinn" <> wrote in message
    > > news:...
    > > > I an developing in C# when i call the following script
    > > > Response.Write("<script>alert('Entry is required')</script>");
    > > > the alert box is displayed
    > > >
    > > > however when the error messge is added in as a varible, no alert box

    is
    > > > displayed
    > > > and i recieve no runtine error,
    > > >
    > > > string errorMessage = "Entry is required";
    > > > Response.Write("<script>alert('" + errorMessage + "')</script>");
    > > >
    > > > Vinny
    > > >
    > > > it just seems as the code is not excuting.Why??
    > > >
    > > > Vinny
    > > >

    > >
    > >
    > >
    William F. Robertson, Jr., Aug 14, 2004
    #3
    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. Charles A. Lackman
    Replies:
    2
    Views:
    7,972
    Charles A. Lackman
    Jan 11, 2006
  2. Matthew Wieder

    Response.Write and Response.Redirect

    Matthew Wieder, Jul 17, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    675
    Kevin Spencer
    Jul 17, 2003
  3. Sehboo
    Replies:
    3
    Views:
    8,762
    Sehboo
    Dec 10, 2003
  4. Replies:
    1
    Views:
    819
  5. slawekg

    Response.Write and Response.Redirect

    slawekg, Jun 21, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    365
    Alexey Smirnov
    Jun 21, 2007
Loading...

Share This Page