Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Trouble with creating an Alert

Posted on 2010-11-15
3
Medium Priority
?
336 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 500 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 500 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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 video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .

963 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