ASP.NET 中的更新面板内的手风琴面板内没有触发按钮
Button not firing inside Accordion Panes inside which is inside Update Panel in ASP.NET
我正在自定义一个网站,但是在更新面板中使用触发器时,点击事件没有触发。
<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);
}
很久以前我也遇到过同样的问题
尝试删除 .aspx 页面上的 Trigger
,然后在 之外的 page_load 添加(注册控件)!page.isPostback{})
ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(btnDownLoads);
看看能不能用
我正在自定义一个网站,但是在更新面板中使用触发器时,点击事件没有触发。
<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);
}
很久以前我也遇到过同样的问题
尝试删除 .aspx 页面上的 Trigger
,然后在 之外的 page_load 添加(注册控件)!page.isPostback{})
ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(btnDownLoads);
看看能不能用