Click here to Skip to main content
11,704,107 members (58,140 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 Sergey Alexandrovich Kryukov 745
1 OriginalGriff 520
2 Maciej Los 475
3 Andy Lanng 284
4 CPallini 275
0 OriginalGriff 8,784
1 Sergey Alexandrovich Kryukov 7,843
2 CPallini 5,107
3 Maciej Los 4,726
4 Mika Wendelius 3,606


Advertise | Privacy | Mobile
Web04 | 2.8.150819.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