0

Code behind getting file upload value is null and inside the update panel using file upload. I also used Triggers tag but I'm getting an error when submitting

ERROR:Object reference not set to an instance of an object.

And also debug but getting a null value of File uploader in code behind. Also, I check for (!IsPostBack) property in page load.

<asp:UpdatePanel ID="UpdatePanel9" runat="server" UpdateMode="Conditional">
    <Triggers><%-- 
        <asp:PostBackTrigger ControlID="lnkbtn_Update_HostScientistLetter_Edit" />
        <asp:AsyncPostBackTrigger ControlID="lnkbtn_Update_HostScientistLetter_Edit"/>--%>
        <asp:AsyncPostBackTrigger ControlID="lnkbtn_Update_HostScientistLetter_Edit" />
    </Triggers>
    <ContentTemplate>
        <div class="col-xs-6">
            <div class="form-group">
                <div class="form-field">
                    <label class="control-label">Host Scientist Letter</label>
                    <br />
                    <div class="table-responsive">
                        <asp:FileUpload ID="FileUpload_HostScientistLetter_Edit" runat="server" CssClass="form-control" Visible="false" />
                        <asp:Label ID="lbl_file_error1" runat="server" ForeColor="Red"></asp:Label>
                        <asp:LinkButton ID="lnkbtn_HostScientistLetter_Edit_update" runat="server" OnClick="lnkbtn_HostScientistLetter_Edit_update_Click" Visible="true"></asp:LinkButton>&nbsp;
                        <asp:LinkButton ID="lnkbtn_change_HostScientistLetter_Edit" ForeColor="#21a04f" runat="server" Text="Click Here to upload new file" OnClick="lnkbtn_change_HostScientistLetter_Edit_Click"></asp:LinkButton>
                        <asp:LinkButton ID="lnkbtn_Update_HostScientistLetter_Edit" ForeColor="#21a04f" runat="server" Text="Update" OnClick="lnkbtn_Update_HostScientistLetter_Edit_Click" Visible="false" ValidationGroup="HostScientistLetter"></asp:LinkButton>
                        <asp:LinkButton ID="lnkbtn_Cancel_HostScientistLetter_Edit" ForeColor="#21a04f" runat="server" Text="Cancel" OnClick="lnkbtn_Cancel_HostScientistLetter_Edit_Click" Visible="false"></asp:LinkButton>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator8" Display="Dynamic" runat="server" ErrorMessage="Upload Host Scientist Letter" ControlToValidate="FileUpload_HostScientistLetter_Edit" ValidationGroup="HostScientistLetter" CssClass="err-msg"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator8" Display="Dynamic" runat="server" ErrorMessage="Only .pdf,.doc,.docx,.ppt  files are allowed." ValidationExpression="^.*\.(PDF|pdf|doc|docx|DOC|DOCX)$" CssClass="err-
 msg" ValidationGroup="HostScientistLetter" ControlToValidate="FileUpload_HostScientistLetter_Edit"></asp:RegularExpressionValidator>
                    </div>
                </div>
            </div>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>
Tamás Szabó
  • 1,388
  • 11
  • 23
Mr doubt
  • 51
  • 1
  • 10
  • 42
  • any help to out this. @Tamás Szabó – Mr doubt Sep 07 '17 at 15:00
  • Possible duplicate of [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – VDWWD Sep 07 '17 at 15:32
  • This is combined question, please try to help na. @VDWWD – Mr doubt Sep 07 '17 at 15:40
  • The error probably comes from code behind. All we see is aspx markup. – VDWWD Sep 07 '17 at 16:14
  • I explained, I am getting file uploader null value code behind? why afer added trigger also inside update panel. @VDWWD – Mr doubt Sep 07 '17 at 16:20
  • My senior told me that If you are tyring to read the value from FileUpload control, then fileupload control wont work inside updatepanel with AsyncPostBackTrigger set. You have to use PostBackTrigger. However this causes a postback which beats the purpose of using updatepanel controls. Still in confused. @VDWWD – Mr doubt Sep 07 '17 at 16:29

0 Answers0