Click here to Skip to main content
12,406,124 members (43,474 online)
Rate this:
 
Please Sign up or sign in to vote.
hi friends

this is my code
<asp:FileUpload ID="FileUpload1" runat="server" />
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
            ControlToValidate="FileUpload1" ErrorMessage="File Required!">
        </asp:RequiredFieldValidator>
        <br />
        <asp:Button ID="Button1" onclick="Button1" runat="server" Text="Upload" />


if no file is selected and click the button it works fine
but
if any file i select and click the button it shows server error
access is denied server error is showing ..
please help me
Posted 20-Mar-13 22:38pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
            ControlToValidate="FileUpload1" ErrorMessage="File Required!" ValidationGroup="a">
        </asp:RequiredFieldValidator>
        <br />
        <asp:Button ID="Button2" runat="server" Text="Button" ValidationGroup="a" />

check this
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

i can't get error by using this code.
Try this code!!
just modify onclick event of button.

aspx:
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="FileUpload1"
       ErrorMessage="File Required!">
   </asp:RequiredFieldValidator>
aspx.cs:
protected void Button1_Click(object sender, EventArgs e)
{
    if (FileUpload1.HasFile)
    {
        newlbl.Text = FileUpload1.PostedFile.FileName;
    }
}
  Permalink  
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160726.1 | Last Updated 21 Mar 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100