Solved

how to keep the file path on fileupload on pagerefresh

Posted on 2009-04-06
3
258 Views
Last Modified: 2013-11-07
1.I did server validation , for the page, dint check for null condition for fileupload , but if user stores other than image files,
for that validation performed., problem here when user select the file ,
 it stores the path but when page loads again the path vanises and becomes null,
 need to keep that path untill d page is clear with all other validations.

2 problem.?How to assign the classname of style to the spancontrol. need to assign the below class to a span control in server side..

.clas1{
visibility:visible;
font:normal 11px "Trebuchet MS", Verdana, Arial;
background-color:#E8F4F9;
color:#003399;
}
<asp:FileUpload ID="FileUpload1" runat="server" Style="left: 232px; position: relative;

            top: 122px" />

 <span id="span1" runat="server" class="lead"></span>
 

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Label1.Text = ""

        If (FileUpload1.FileName.ToString() <> "") And (Not Regex.IsMatch(FileUpload1.FileName.ToString(), "!/(\.img|\.png|\.gif|\.bmp|\.jpg)$/i")) Then

            Label1.Text = "only image files"

        End If

Open in new window

0
Comment
Question by:Rajar Ahmed
  • 2
3 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 24075110
The FileUpload control is designed to forget the filename to avoid security problems. When the button is clicked, the file is uploaded already so the filename is cleared. In the button click event, you should either save the file if it is image file or set an error message if it is not image file.
0
 
LVL 18

Author Comment

by:Rajar Ahmed
ID: 24075239
thanks.....I had did the error message othr than image files,

can u suggest for my second query...?
 
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24075260
May be this
<span id="span1" runat="server" class="clas1"></span>
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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 …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now