C# Web用户控件中未引发ASP.NET按钮事件
我有一个ASP.NET用户控件,它包含一个Telerik报表查看器和一个按钮(服务器控件) 我需要处理按钮单击事件中的一些内容,但该事件似乎没有触发 有人知道为什么会这样吗 以下是UserControl中的HTML指令:C# Web用户控件中未引发ASP.NET按钮事件,c#,asp.net,events,C#,Asp.net,Events,我有一个ASP.NET用户控件,它包含一个Telerik报表查看器和一个按钮(服务器控件) 我需要处理按钮单击事件中的一些内容,但该事件似乎没有触发 有人知道为什么会这样吗 以下是UserControl中的HTML指令: <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ReportControl.ascx.cs" Inherits="TelerikReportCustomRetrive.UserControl.Rep
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ReportControl.ascx.cs" Inherits="TelerikReportCustomRetrive.UserControl.ReportControl" %>
<form runat="server" id="form1">
<telerik:ReportViewer ID="ReportViewer1" runat="server" Height="461px" ShowDocumentMapButton="False" ShowHistoryButtons="False" ShowNavigationGroup="False" ShowParametersButton="False" ShowPrintPreviewButton="False"></telerik:ReportViewer>
<asp:Button runat="server" ID="btnNav" OnClick="btnNav_Click" />
删除if(!PostBack)语句。您应该始终初始化控件,而不仅仅是在页面未回发的情况下。请发布您的代码,包括定义了未触发按钮的标记以及按钮事件处理程序的隐藏代码(C#)。现在。。你有我的朋友请提供你的HTML代码。你在你的页面中使用了updatePanel吗?你在
btnNav\u Click
上放置了一个断点,并验证了它没有被调试器命中?我这样做了,但没有发生任何事情这不是真的。根据控件的不同,它可能会将其保持在viewstate中。
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
var instanceReportSource = new InstanceReportSource
{
ReportDocument =
new TheReport()
};
ReportViewer1.ReportSource = instanceReportSource;
}
}
protected void btnNav_Click(object sender, EventArgs e)
{
Response.Write("Button Fired!");
}