如何清除asp.net中的查询字符串值 [英] How to clear Query string value in asp.net
本文介绍了如何清除asp.net中的查询字符串值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何清除查询字符串值。
示例:
Hi,
How to Clear the Query String value.
Example:
response.write("sample.aspx?id=3")
iam getting这个价值另一页如
iam getting this value another page like
int id=request.querystring["id"];
我想在更新方法中清除此值。
使用以下内容
I want to clear this value in update method.
iam using followings
Response.ClearContent();
Request.QueryString.Remove("id");
但不清楚
$ b $bThanks®ards
venkat
but it is not clears
Thanks®ards
venkat
推荐答案
要清除所有查询字符串,您可以调用Request.QueryString.Clear();
将删除网址上的所有查询字符串
删除特定的查询字符串调用Request.QueryString.Remove(查询字符串的名称),
例如:
To clear all querystrings, you can invoke the Request.QueryString.Clear();
which will remove all the querystrings at the url
To remove a specific querystring invoke Request.QueryString.Remove("name of the querystring"),
example:
http://www.mypage.aspx?id=123
Request.QueryString.Remove("id");
或者你可以使用
or you can use
Request.QueryString.Clear();
将删除或查询字符串
示例
which will remove or the querystrings
example
http://www.mypage.aspx?id=123&date=29/8/2008
Request.QueryString.Clear();
结果
没有两个查询字符串的URL(id,日期);
result
Url without the two querystrings (id,date);
PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);
// make collection editable
isreadonly.SetValue(this.Request.QueryString, false, null);
// remove
this.Request.QueryString.Remove("id");
您好用上面的代码解决了这个问题
Hi solved this using the above code
您可以使用
you can use
Request.QueryString.Clear();
用于清除所有查询字符串
for clear all the query string
这篇关于如何清除asp.net中的查询字符串值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文