Solved

Trouble with creating an Alert

Posted on 2010-11-15
3
328 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 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