Click here to Skip to main content
11,645,087 members (68,592 online)
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 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
0 OriginalGriff 700
1 jyo.net 684
2 Sergey Alexandrovich Kryukov 473
3 CPallini 426
4 Afzaal Ahmad Zeeshan 418
0 OriginalGriff 1,065
1 Sergey Alexandrovich Kryukov 703
2 Afzaal Ahmad Zeeshan 702
3 DamithSL 681
4 CPallini 595


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