Click here to Skip to main content
15,891,993 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
dear sir;

i am using this code for upload file in asp.net

it is work nicely when i use saperate page(without master page )
but when it use with master page and debuge it then upload.HasFile false jump to
try block part.



how to solve it..

VB
Protected Sub btnupload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnupload.Click
       If upload.HasFile Then
           Try
               'Dim fileName As String = Path.GetFileName(Me.fileResume.FileName)
               Dim filename As String = Path.GetFileName(Me.upload.FileName)
               'Session("sessionfilename") = filename
               upload.SaveAs(Server.MapPath("~/IMEINO/") & filename)
           Catch ex As Exception

           Finally
               lblMsg.Text = "<font color='green'>Data Insert Sucessfully</font>"
               lblMsg.ForeColor = System.Drawing.Color.Red

           End Try
       End If
   End Sub



here is ,,..

XML
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false"
    CodeFile="AddIMEI.aspx.vb" Inherits="AddIMEI" Title="Ultimate RMA : IMEI NO." %>

<asp:Content ID="Content1" ContentPlaceHolderID="cph1" runat="Server">
    <div style="width: 960px;" align="left">
        <asp:UpdatePanel ID="updpnlOrderParts" runat="server">
            <ContentTemplate>

<pre lang="xml"><div>
                    <table width="100%">
                        <tr>
                            <td align="right" style="width: 50%;">
                                <asp:FileUpload ID="upload" runat="server" />
                            </td>
                            <td align="left">
                                <asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                            </td>
                            <asp:Label ID="lblMsg" runat="server"></asp:Label>
                        </tr>
                    </table>
                </div>
                <div>
                    <table width="100%">
                        <tr>
                            <td  align="center" >
                            <asp:Button ID="btnInsert" runat="server" Text="Add IMEINO" />


                            </td>
                        </tr>
                    </table>
                </div>

</div>
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Content>

Posted
Updated 14-Jul-11 19:46pm
v2

this link might help you
File Upload with ASP.NET[^]
 
Share this answer
 
Just answered a similar question here[^].
 
Share this answer
 

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