我有两个项目。在第一个项目中,更新面板正常工作,但相同的代码(复制粘贴时相同的页面)不起作用并完全回发。我的代码很简单,是:
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
在第二个项目中,我使用以下代码的global.asax:
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RegisterRoute(System.Web.Routing.RouteTable.Routes);
}
void RegisterRoute(System.Web.Routing.RouteCollection routes)
{
//routes.Add("Company", new System.Web.Routing.Route("{category}", new CategoryRouteHandler()));
routes.MapPageRoute("catid","{catid}", "~/Company.aspx");
}
答案 0 :(得分:0)
如下所示更改RegisterRoute。更多信息check this
void RegisterRoute(System.Web.Routing.RouteCollection routes)
{
//routes.Add("Company", new System.Web.Routing.Route("{category}", new CategoryRouteHandler()));
routes.MapPageRoute("catid", "{catid}", "~/Company.aspx",false);
}
答案 1 :(得分:0)
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button"/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
</form>