Solved

Trouble with creating an Alert

Posted on 2010-11-15
3
324 Views
Last Modified: 2012-08-13
Trying to raise an alert with the following code.            

string message = String.Format("The file you are attempting to upload is {0} bytes.\n\r"
                                +          "     The maximum allowable size if {1} bytes.\n\r"
                                +          "               File not uploaded!!!",  
                                           fileUpload.FileBytes.GetLength(0),
                                           _MAX_PIC_SIZE);
                                           
            ClientScript.RegisterStartupScript(this.GetType(), "openWin", "<scriptlanguage=JavaScript>alert('" + (message) + "');</script>");

Also tried:
            const string PREFIX = "<script language=\"javascript\"> window.open('+htmlPath+','Alert','toolbar=no,status=no,menubar=no,location=center,scrollbars=no,resizable=no,height=500,width=350');<";

            cmd.Parameters.AddWithValue("@ImageData", null);

            string message = String.Format("The file you are attempting to upload is {0} bytes.\n\r"
                                +          "     The maximum allowable size if {1} bytes.\n\r"
                                +          "               File not uploaded!!!",  
                                           fileUpload.FileBytes.GetLength(0),
                                           _MAX_PIC_SIZE);

            ClientScript.RegisterStartupScript(this.GetType(), "Startup", PREFIX + (message) + ">');</script>");

The code is executed and the file is not uploaded but I don't see the alert message.  Using IE 8.

What am I doing wrong?
0
Comment
Question by:Marvin_Rowe
3 Comments
 
LVL 3

Accepted Solution

by:
danora earned 125 total points
ID: 34138024
Hi Marvin Rowe,

Have you tried enabling compatibility mode within IE? I had some issues similar and this simple fix worked for mine :)
0
 
LVL 13

Assisted Solution

by:devlab2012
devlab2012 earned 125 total points
ID: 34138073
You are missing a space in "<scriptlanguage". It should be like "<script language". complete line is:
ClientScript.RegisterStartupScript(this.GetType(), "openWin", "<script language=JavaScript>alert('" + (message) + "');</script>");
0
 

Author Comment

by:Marvin_Rowe
ID: 34191965
Both are acceptable solutions - can I award each of you 125 points?

Thanks and sorry it has taken me so long to get back to you.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 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

16 Experts available now in Live!

Get 1:1 Help Now