Solved

how to keep the file path on fileupload on pagerefresh

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

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.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

773 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