Removing a querystring from url in asp.net

后端 未结 4 668
[愿得一人]
[愿得一人] 2020-12-18 15:36

HI, I need to remove a querystring when a user clicks a particular LinkButton. So for example if the querystring is http://UserProfileManager.com?UserID=1234 .... when the u

4条回答
  •  被撕碎了的回忆
    2020-12-18 15:56

    You have several options:

    1) In your code behind, just set the LinkButton's URL to the shorter address if the querystring contains a "UserID" key:

    if (Request.QueryString["UserID"] != null) {
        this.LinkButton.PostBackUrl = "http://UserProfileManager.com";
    } else {
        // other address
    }
    

    2) Send the UserID in a hidden field instead of the querystring.

    3) Separate your view and edit pages - putting everything in one *.aspx is probably going to cause more trouble than it's worth down the road.

提交回复
热议问题