Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to upload some files and send as an email. I have two update panels because, when I click the Menu item, it automatically refreshes the whole page and hence no file will be attached. How do I stop it?
I want my page to hold the files until I click Button3. Then it can perform the function of sending the email.
Attached is my code

ASP.NET
<%@ Page Title="Home Page" Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EDMSProject._Default" %>


<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <style type="text/css">
        .auto-style2 {
            width: 186px;
        }
    </style>
    </head>
<body>
<form id="form1" runat="server">   
    <asp:Label ID="Label1" runat="server" Text="Label">
    <br />
        
    <br />
    
    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Check DocuTray " />
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
       <contenttemplate>
    <asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="True" />
    <br />
            </contenttemplate>
        <triggers>
        <asp:PostBackTrigger ControlID = "Button3"/>     
    </triggers>
    

         <asp:UpdatePanel ID="UpdatePanel2" runat="server">
       <contenttemplate>
    
        <asp:Button ID="Button2" runat="server" Text="Check History/Status" />
       
       
             <asp:Menu ID="Menu1" runat="server" OnMenuItemClick="Menu1_MenuItemClick" Orientation="Horizontal" style="margin-left: 41px">
                 <items>
                     <asp:MenuItem Text="Action" Value="Action">
                         <asp:MenuItem Text="Forward" Value="Forward">
                         <asp:MenuItem Text="Save" Value="Save">
                         <asp:MenuItem Text="Close Ticket" Value="Close Ticket">
                     
                 </items>
                 <staticitemtemplate>
                     <%# Eval("Text") %>
                 </staticitemtemplate>
              
                
              <asp:Label ID="Label2" runat="server" Text="Department">
              <asp:DropDownList ID="DropDownList1" runat="server" DataTextField="Department" DataValueField="Department" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
              
              <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:EDMSConnectionString %>" SelectCommand="SELECT * FROM [Employee]">
       <br />
              <asp:Label ID="Label3" runat="server" Text="Client">
       <asp:DropDownList ID="DropDownList2" runat="server">
           <asp:ListItem>Pavis
           <asp:ListItem>Dove Associates
              
        <br />
       <asp:Label ID="Label4" runat="server" Text="Recipient">
       <asp:DropDownList ID="DropDownList3" runat="server">
              <asp:ListBox ID="ListBox1" runat="server" SelectionMode="Multiple">
       <br />
       <asp:Label ID="Label6" runat="server" Text="Subject">
       <asp:TextBox ID="TextBox2" runat="server" Width="182px">
        <br />
       <asp:Label ID="Label5" runat="server" Text="Message">
       <asp:TextBox ID="TextBox1" runat="server" Height="109px" Width="265px">
       <br />
       <asp:Button ID="Button3" runat="server" Text="Button" OnClick="Button3_Click" style="margin-left: 260px" />
             </contenttemplate> 
                  
            
      
</form>     
    </body>
</html>


Department
Posted
Updated 26-Apr-14 10:13am
v3
Comments
ZurdoDev 26-Apr-14 21:27pm    
The client can't hold on to the files, at least not with the fileupload control. Once the user picks the file it automatically posts back.

1 solution

See your button3 need to be placed inside updatepanel1. If you are using for fileupload

 <asp:updatepanel id="UpdatePanel1" runat="server" xmlns:asp="#unknown">
       <contenttemplate>
    <asp:fileupload id="FileUpload1" runat="server" allowmultiple="True" />
    <br />
 <asp:button id="Button3" runat="server" text="Button" onclick="Button3_Click" style="margin-left: 260px" />

            </contenttemplate>
        <triggers>
        <asp:postbacktrigger controlid="Button3" />     
    </triggers>

</asp:updatepanel>


Or you can use whole of the page in a single updatepanel
for more information see this article
Using-FileUpload-Control-inside-ASP.Net-AJAX-UpdatePanel-Control.aspx[^]
 
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