Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Everyone,
My MessageBox.show is not working.Kindly help
C#
protected void Button3_Click(object sender, EventArgs e)
    {
        string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
        int fileLengthInKB = FileUpload1.PostedFile.ContentLength;
        if (FileUpload1.HasFile)
        {
            if (fileLengthInKB < 1048576)
            {
                FileUpload1.PostedFile.SaveAs(Server.MapPath("~/upload/") + fileName);
                Response.Redirect(Request.Url.AbsoluteUri);
            }
            else
            {
                MessageBox.Show("Enter a file less than 1 MB");
            }
        }

    }
Posted
Updated 30-Apr-14 0:52am
v2
Comments
[no name] 30-Apr-14 7:07am    
I would bet that it is working just fine. Your users will never see a messagebox on your website. It would be displayed on your webserver.

I believe you got some trouble until you got the right reference to MessageBox...Didn't you noticed that it's a reference to Windows Forms?!
MessageBox is for desktop application - you are in the word of web!!!
According to you code you try to validate file size - why not to use validation controls?
http://msdn.microsoft.com/en-us/library/debza5t0(v=vs.100).aspx[^]
 
Share this answer
 
You can use this
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Your Message');", true);
 
Share this answer
 
Comments
Member 10578683 1-May-14 1:35am    
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900