C# 在ASP.NET中的更新面板内,手风琴窗格内的按钮未启动
我正在自定义一个网站,但在更新面板中使用触发器时,单击事件没有触发C# 在ASP.NET中的更新面板内,手风琴窗格内的按钮未启动,c#,asp.net,C#,Asp.net,我正在自定义一个网站,但在更新面板中使用触发器时,单击事件没有触发 <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="True" 另请参见触发器 另请参见按钮点击背后的代码:- protected void btnDownLoads_Click(object sender, EventArgs e) { string wd
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="True"
另请参见触发器
另请参见按钮点击背后的代码:-
protected void btnDownLoads_Click(object sender, EventArgs e)
{
string wdr = "dR";
string value = txtDate.Text;
string str = wdr + value;
string foldername = "Daily";
string filename = str + ".pdf";
var filePath = Path.Combine(@"D:\REPORTS\" + foldername + " ", filename);
if (File.Exists(filePath))
{
Response.ContentType = @"application/pdf";
Response.AddHeader(
@"Content-Disposition",
@"attachment; filename=" + Path.GetFileName(filePath));
Response.WriteFile(filePath);
Response.End();
}
else
{
Response.Write("<script>alert('No report uploaded for this date')</script>");
}
}
很久以前我也遇到过同样的问题 尝试删除.aspx页面上的
触发器
,并在页面上添加(注册控件)如下所示的代码\u加载到外部!page.isPostback{})
查看它是否工作您的意思是在按钮单击事件之后文件没有传输到客户端???@Mr。香港人: 是的,单击按钮时没有任何事情发生。由于更新面板停止了文件传输到客户端,请尝试删除更新面板,看看它是否工作。@Mr。香港人: 我试过了,但仍然没有发生任何事情。然后尝试response.transmitfile而不是WriteFile
protected void btnDownLoads_Click(object sender, EventArgs e)
{
string wdr = "dR";
string value = txtDate.Text;
string str = wdr + value;
string foldername = "Daily";
string filename = str + ".pdf";
var filePath = Path.Combine(@"D:\REPORTS\" + foldername + " ", filename);
if (File.Exists(filePath))
{
Response.ContentType = @"application/pdf";
Response.AddHeader(
@"Content-Disposition",
@"attachment; filename=" + Path.GetFileName(filePath));
Response.WriteFile(filePath);
Response.End();
}
else
{
Response.Write("<script>alert('No report uploaded for this date')</script>");
}
}
try
{
this.SmartNavigation = true;
if (this.IsPostBack == false)
{
//FillReport();
txtDate.Text = DateTime.Now.ToString("dd-MM-yyyy");
cal.Visible = false;
currentdate.Text = DateTime.Now.Date.ToLongDateString();
#region edited
#region download click
checkdailydata();
#endregion
#endregion
}
}
catch (Exception ext) // Edited Jimit included try catch
{
CreateLogFiles ls = new CreateLogFiles();
ls.ErrorLog(Server.MapPath(@"~\ErrorLog\ErrorMsg"), ext.Message);
}
ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(btnDownLoads);