Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Trouble with creating an Alert

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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…

808 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