I am creating a web page for a fileupload requirement. Every page has a MasterType Template. Which I include in my aspx files like the following:
<%@ MasterType VirtualPath="~/MasterPage/Main.master" %>
I followed what I found online for implementing the fileupload function using Update Panel:
<asp:Panel ID="panel_Actions" runat="server">
<asp:UpdatePanel ID="upanel_Actions" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:Button ID="btn_downloadEmpTemplate" runat="server" OnClick="btn_downloadEmpTemplate_Click" Text="Download Template"/>
<asp:FileUpload runat="server" ID="fu_excelUpload" />
<asp:Button ID="btn_uploadSubmit" runat="server" OnClick="btn_UploadSubmit_Click" Text="Upload"/>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btn_uploadSubmit" />
</Triggers>
</asp:UpdatePanel>
</asp:Panel>
Whenever I press the submit (btn_uploadSubmit
) the Master Page Template completely disappears. And I'm left only with the page content. What is happening?
My pageLoad
and my onclick
function for the upload submit:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
System.Web.UI.ScriptManager.GetCurrent(this).RegisterPostBackControl(this.btn_downloadEmpTemplate);
}
protected void btn_UploadSubmit_Click(object sender, EventArgs e)
{
string s = this.fu_excelUpload.FileName;
}
EDIT: I think the issue may be related to the way the script manager was implemented in this project. It exists within the master template instead of the page. Including some of the master code:
<head>...</head>
<body>
<form id="form" runat="server" >
<asp:ToolkitScriptManager ID="tsm" runat="server" AjaxFrameworkMode="Enabled" AsyncPostBackTimeout="1800" EnablePartialRendering="true" LoadScriptsBeforeUI="true" ScriptMode="Auto"></asp:ToolkitScriptManager>
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div> // main content content template here
<script>...</script>
</form>
</body>
</html>