开发者

Set URL argument for Page_Load in some menu item click Javascript

开发者 https://www.devze.com 2023-02-07 10:55 出处:网络
I am reimplementing an ASP.NET application with a main page (Call it \"MyMainPage\") which contains a user control.(Call it \"MyNavControl\")Withi开发者_StackOverflow社区n that user control is a menu

I am reimplementing an ASP.NET application with a main page (Call it "MyMainPage") which contains a user control. (Call it "MyNavControl") Withi开发者_StackOverflow社区n that user control is a menu control provided by a third party. Items added to this third party control have an "Href" property that is passed a URL. The code to create a menu subitem, contained within the codebehind of the .ascx for MyNavControl, goes something like this:

ThirdParty.MenuItem subitem = new ThirdParty.MenuItem();
subitem.Href="MyMainPage.aspx?_page=PremiumCustomer&_title=Premium";

MyMainPage also contains a user control representing the bulk of the page body. Let's call that MainBodyControl.ascx. The Page_Load() for the main page sets up some session values which are used in the Page_Load() for MainBodyControl.

When the menu item on the main page is clicked, the main page's Page_Load() will be passed the arguments specified in the menu item control's "Href" value. So:

protected void Page_Load(object sender, System.EventArgs e)
{
    string sPageType = "";
    if (this.Request[ "_page" ] != null) {
        sPageType = this.Request[ "_page" ].ToString();
    }
}

Here's my question: I'm replacing the third party controls with standard ASP.NET controls, so the current "Href" property mechanism can no longer be used. What would be the best way, in some JavaScript assigned to a menu item's click event, to set a new value for "_page" or "_title" above.


You can write

<asp:MenuItem NavigateUrl="MyMainPage.aspx?_page=PremiumCustomer&_title=Premium"
              Text="Click here!" />
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号