?
Solved

Stringbuilder Alert Box

Posted on 2007-08-10
6
Medium Priority
?
286 Views
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?

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() )
0
Comment
Question by:Cleavis
  • 3
5 Comments
 
LVL 41

Expert Comment

by:HonorGod
ID: 19670268
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.
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 19670522
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()".
0
 

Author Comment

by:Cleavis
ID: 19670999
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.
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 19671429
Good.  Glad to hear it.

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

Accepted Solution

by:
Computer101 earned 0 total points
ID: 19945045
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…
Suggested Courses

750 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