Link to home
Start Free TrialLog in
Avatar of Cleavis
Cleavis

asked on

Stringbuilder Alert Box

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?

Thanks!

Chris


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() )
Avatar of HonorGod
HonorGod
Flag of United States of America image

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.
by the way, exactly what do you have as your StringBuilder definition.  The one I see from here (http://www.codeproject.com/jscript/stringbuilder.asp) has "toString()" defined, but not "ToString()".
Avatar of Cleavis
Cleavis

ASKER

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.
Good.  Glad to hear it.

That sounds like a .NET thing, rather than a StringBuilder thing though.
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial