Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi friends

this is my code
XML
<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

XML
<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
 
Share this answer
 
i can't get error by using this code.
Try this code!!
just modify onclick event of button.

aspx:
C#
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="FileUpload1"
       ErrorMessage="File Required!">
   </asp:RequiredFieldValidator>
   <br />
   <asp:Button ID="Button1" runat="server" Text="Upload" onclick="Button1_Click" />
   <asp:Label ID="newlbl" runat="server"></asp:Label>

aspx.cs:
C#
protected void Button1_Click(object sender, EventArgs e)
{
    if (FileUpload1.HasFile)
    {
        newlbl.Text = FileUpload1.PostedFile.FileName;
    }
}
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900