允许回发特定面板HTML,ASP.NET [英] Allow Postback for a Specific Panel HTML, ASP.NET

查看:80
本文介绍了允许回发特定面板HTML,ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试上传一些文件并作为电子邮件发送。我有两个更新面板,因为当我单击菜单项时,它会自动刷新整个页面,因此不会附加任何文件。如何阻止它?

我希望我的页面保存文件,直到我点击Button3。然后它可以执行发送电子邮件的功能。

附上我的代码



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

<%@ 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

推荐答案

ConnectionStrings:EDMSConnectionString %> SelectCommand = SELECT * FROM [Employee] >
< br / >
< asp:标签 ID = Label3 runat = server 文字 = 客户端 >
< asp:DropDownList ID = DropDownList2 runat = server >
< < span class =code-leadattribute> asp:ListItem > Pavis
< asp:ListItem > ; Dove Associates

< br / >
< asp:标签 ID = Label4 runat = server 文字 = 收件人 >
< asp:DropDownList ID = DropDownList3 runat = 服务器 >
< asp:ListBox ID = ListBox1 runat < span class =code-keyword> = server SelectionMode = Multiple >
< br / >
< asp:Label ID = Label6 runat = server 文本 = 主题 >
< asp:TextBox ID = TextBox2 runat = server 宽度 = 182px >
< br / >
< asp:Label ID = Label5 runat = server 文本 = 消息 >
< 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>
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



Department


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



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[^]


这篇关于允许回发特定面板HTML,ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆