Stringbuilder Alert Box

Posted on 2007-08-10
Last Modified: 2013-12-08
We are using Stringbuilder to create a Javascript alert box to display data to our users.

The following code works when I run the app in IE6 but not in IE7.

Does anybody have a solution for this issue?



DclFld sb1 Type( StringBuilder ) New( 128 )
DclFld Message Type( *String )
Message = "THIS IS A TEST"

sb1.Append( Environment.NewLine + "<script language=javascript>" + Environment.NewLine)
sb1.Append( "    alert('" + Message + "'); "     + Environment.NewLine)
sb1.Append( "</script>" + Environment.NewLine )
*this.Page.RegisterStartupScript( "Alert", sb1.ToString() )
Question by:Cleavis
    LVL 41

    Expert Comment

    I'm sorry, but I'm confused.  What doesn't work in IE7?
    is it the StringBuilder code, or the .net stuff used to write the StringBuilder script code?
    When you "view source" on IE6 and IE7, are they identical?

    If so, remove the .NET code from the equation, and have a simple HTML + JavaScript page that works on IE6, but fails on IE7.
    LVL 41

    Expert Comment

    by the way, exactly what do you have as your StringBuilder definition.  The one I see from here ( has "toString()" defined, but not "ToString()".

    Author Comment

    I could not get the alert box to display in IE7 but it did in IE6... I have corrected this with the following.

    Page.ClientScript.RegisterStartupScript(*typeof(*String),'Alert','alert("' + sb1.ToString() + '")',*true)

    This appears to be working properly.
    LVL 41

    Expert Comment

    Good.  Glad to hear it.

    That sounds like a .NET thing, rather than a StringBuilder thing though.
    LVL 1

    Accepted Solution

    PAQed with points refunded (500)

    EE Admin

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Suggested Solutions

    Internet is a big network which is formed by connecting multiple small networks.It is a platform for all the users which are connected to it.Internet act as platform in different fields. Such as: Internet  as a collaboration platform. Internet  as…
    Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
    The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
    THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now