TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
vishal mewara
NA
12
34.3k
The message of Label on web page remains as it is on refresh
Feb 6 2014 11:03 AM
My Default.aspx Code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="FileUploadImage" runat="server" />
<asp:Button ID="ButtonImageUpload" runat="server" OnClick="ButtonImageUpload_Click" Text="Upload Image" Width="112px" />
<br />
<br />
<asp:Label ID="LabelImageUploadMessage1" runat="server" Text=""></asp:Label>
<asp:Label ID="LabelImageUploadMessage2" runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>
and
My Default.aspx.cs Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ButtonImageUpload_Click(object sender, EventArgs e)
{
if (FileUploadImage.HasFile)
{
string ImageExtension = System.IO.Path.GetExtension(FileUploadImage.FileName);
if (ImageExtension.ToLower() != ".png" && ImageExtension.ToLower() != ".jpg" && ImageExtension.ToLower() != ".jpeg")
{
LabelImageUploadMessage2.Text = "Only Files with .png or .jpg or .jpeg Accepted.";
LabelImageUploadMessage2.ForeColor = System.Drawing.Color.Red;
}
else
{
int ImageSize = FileUploadImage.PostedFile.ContentLength;
if (ImageSize > 2097152)
{
LabelImageUploadMessage2.Text = "File Size Should be less than 2 MB.";
LabelImageUploadMessage2.ForeColor = System.Drawing.Color.Red;
}
else
{
FileUploadImage.SaveAs(Server.MapPath("~/Upload/" + FileUploadImage.FileName));
LabelImageUploadMessage1.Text = "File Uploaded";
LabelImageUploadMessage1.ForeColor = System.Drawing.Color.Green;
}
}
}
else
{
LabelImageUploadMessage2.Text = "Please Select a File To Upload.";
LabelImageUploadMessage2.ForeColor = System.Drawing.Color.Red;
}
}
}
Reply
Answers (
1
)
We found Vulpes
Set Zoom Level of Generated Presentation & SmartArt Editing