Solved

how to keep the file path on fileupload on pagerefresh

Posted on 2009-04-06
3
263 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Icons and Colors for Terms 3 24
How to deploy to IIS 7 on 2008R2 server with DUO 2-step login? 2 37
Export import database 4 44
Close form "before" open 3 28
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

862 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

23 Experts available now in Live!

Get 1:1 Help Now