我正在自定义一个网站,但是,在更新面板中使用触发器时,点击事件未触发。
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="True"
另见Content Template
<ContentTemplate>
<table width="100%">
<tr>
<td>
<cc1:accordion id="Accordion1" runat="server" headercssclass="headeraccordian">
<panes>
<cc1:accordionpane ID="AccordionPane1" runat="server">
<header>
<a href="#">
<asp:Label ID="dailyreport" CssClass="lbl" runat="server" Text="Daily Report"></asp:Label></a>
</header>
<content>
<div>
<asp:TextBox ID="txtDate" runat="server" ReadOnly="True" Width="94px"></asp:TextBox>
<asp:Button ID="btnCal" runat="server" Text="Select Date" OnClick="btnCal_Click" />
<asp:Button ID="btnDownLoads" runat="server" Text="Download" OnClick="btnDownLoads_Click" />
<asp:Calendar ID="cal" runat="server" OnSelectionChanged="cal_SelectionChanged" BackColor="White"
BorderColor="White" BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black"
Height="190px" NextPrevFormat="FullMonth" Width="350px">
<SelectedDayStyle BackColor="#333399" ForeColor="White" />
<TodayDayStyle BackColor="#CCCCCC" />
<OtherMonthDayStyle ForeColor="#999999" />
<NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333" VerticalAlign="Bottom" />
<DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
<TitleStyle BackColor="White" BorderColor="Black" BorderWidth="4px" Font-Bold="True"
Font-Size="12pt" ForeColor="#333399" />
</asp:Calendar>
</div>
</content>
</cc1:accordionpane>
</panes>
</cc1:accordion>
</td>
</tr>
</table> </ContentTemplate>
另见触发器
另请参阅按钮单击的代码隐藏: -
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>");
}
}
我只想在点击时点击事件,这是.............
但下载文件时Response.End()
功能无法正常工作。
请参阅page_load
代码; -
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);
}
答案 0 :(得分:0)
长期以来我也面临同样的问题
尝试删除.aspx页面上的Trigger
并在!page.isPostback {})之外的 page_load 上添加(注册控制)如下代码p>
ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(btnDownLoads);
查看它是否有效