母版页中的更新面板和子页面中的asp文件上载

Ste*_*Soh 2 html c# asp.net ajax

我正面临一个问题,目前我的母版页和我的子页面中有一个更新面板,我有一个asp文件上传控件.

我在主人的更新面板[年龄:

    <form id="form1" runat="server">
      <asp:ScriptManager ID="ScriptManager1" runat="server">
     </asp:ScriptManager>

     <asp:updateprogress associatedupdatepanelid="UpdatePanel1"
        id="updateProgress" runat="server">
         <progresstemplate>
            <div id="processMessage" style=" background-image:url('../../Styles/ajax-loader3.gif'); width:100px; height:100px; background-repeat:no-repeat; background-position:center;">

               </div>
        </progresstemplate>
    </asp:updateprogress> 

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
     <ContentTemplate>
..
    </ContentTemplate>
 </asp:UpdatePanel>
</form>
Run Code Online (Sandbox Code Playgroud)

My Child页面需要fileupload:

<div id="Annoucments" class="ContentDIV">
            <h2 class="Tabheader">Annoucments</h2>
            <p class="tabdescription">Here you will be able to upload announcements and pictures to be displayed in the login page, below is the current announcement click on update to save the changes that you have made.</p>

            <table width = "100%">

            <tr>
            <td class="Tablabel">Annoucment title:</td> <td class="tableInput" align="left"><asp:TextBox ID="Announcement_TB" runat="server" CssClass="textboxTabs"></asp:TextBox></td>
            <td class="Tablabel">Picture/Poster:</td> <td class="tableInput" align="left"><asp:FileUpload ID="Announcement_PIC" runat="server"  CssClass="textboxTabsFiles"/></td>
            </tr>

            <tr>
            <td class="Tablabel">Description:</td> <td class="tableInput" align="left"><asp:TextBox ID="Announcement_Desc" CssClass="textboxTabs" runat="server" Rows="3" TextMode="MultiLine"></asp:TextBox></td>
            </tr>

            <tr><td colspan="4" style="height:10px" id ="BLANK">
                <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                </td></tr>

            <tr>
            <td colspan="2" align="right"><input type="button" id="Announcement_Update" runat="server" value="Update" class="TabButton" onserverclick="ANNOUNCEMENT_UPDATE_Click" style=" font-size:smaller"/></td><td colspan="2">&nbsp;&nbsp;<input type="button" ID="ANNOUNCEMENT_Cancel" runat="server" value="Cancel" class="TabButton" style=" font-size:smaller"/></td>  
            </tr>

            </table>

        </div>
Run Code Online (Sandbox Code Playgroud)

*当我点击按钮Announcement_Update后端代码将被触发以获取我的文件名时,返回的文件名将始终在调试时找到.*

Nar*_*iya 8

将此代码放在子页面中,以传递PostBackTrigger以进行文件上载.

protected void Page_Load(object sender, EventArgs e)
{
    UpdatePanel updatePanel = Page.Master.FindControl("UpdatePanel1") as UpdatePanel;
    UpdatePanelControlTrigger trigger  = new PostBackTrigger();
    trigger.ControlID = Announcement_Update.UniqueID;
    updatePanel.Triggers.Add(trigger);
}
Run Code Online (Sandbox Code Playgroud)

享受编码:)