Solved

Trouble with creating an Alert

Posted on 2010-11-15
3
330 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
[X]
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
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

617 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