updatepanel无法在特殊解决方案中使用

时间:2014-08-26 18:48:00

标签: asp.net

我有两个项目。在第一个项目中,更新面板正常工作,但相同的代码(复制粘贴时相同的页面)不起作用并完全回发。我的代码很简单,是:

<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");
} 

2 个答案:

答案 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>