Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB ASP.NET HTML ASM jQuery , +
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 23: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>
    <br />
    <asp:Button ID="Button1" runat="server" Text="Upload" onclick="Button1_Click" />
    <asp:Label ID="newlbl" runat="server"></asp:Label>
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)



Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 21 Mar 2013
Copyright © CodeProject, 1999-2014
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