在asp.net中删除查询字符串的URL字符串、asp、net、URL

由网友(不過如此)分享简介:我需要当用户点击一个特定的LinkBut​​ton删除查询字符串。因此,例如,如果查询字符串是 http://UserProfileManager.com?UserID=1234 ....当用户点击LinkBut​​ton的,我想要的网址是 http://UserProfileManager.com 。问题是,一切...

我需要当用户点击一个特定的LinkBut​​ton删除查询字符串。 因此,例如,如果查询字符串是 http://UserProfileManager.com?UserID=1234 ....当用户点击LinkBut​​ton的,我想要的网址是 http://UserProfileManager.com 。问题是,一切都在一个页面上,而我使用的ASP:面板来显示和隐藏网页的不同区域

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 user clicks on the Linkbutton, I want the url to be http://UserProfileManager.com. The issue is that everything is on one page, and I am using asp:panel to show and hide different areas of the webpage.

任何想法,将AP preciated。

Any ideas would be appreciated.

推荐答案

您有几种选择:

1)在你的code后面,只需设置的LinkBut​​ton的URL到更短的地址,如果查询字符串中包含一个用户名键:

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)发送在一个隐藏字段,而不是查询字符串的用户名。

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

3)分离视图和编辑页面 - 把一切都在一个*的.aspx很可能会造成更多的麻烦比它的价值在路上

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.

阅读全文

相关推荐

最新文章