D
David
Hello
I need to take some values and place them in a string in
the format of a querystring.
Lets say I have:
string State = "ACT";
string SearchString = "Tax";
int MinRelevance = 50;
I want to create the string:
"?State=ACT&SearchString=Tax&MinRelevance=50"
This will then be placed on the end of the relevant URL,
and placed in an anchor tag on the resulting page, so the
user can click on that link.
Now in an ideal world, I would be able to do:
System.Web.QueryString x = new System.Web.QueryString();
x.Add("State", State);
x.Add("SearchString", SearchString);
x.Add("MinRelevance", MinRelevance);
return (x.ToString());
At the moment, I am looking at writing my own function to
do this. It will take a namevaluecollection, and iterate
through those, creating the querystring. Then I would
have to use System.Web.HttpUtility.UrlEncode. I would
assume I will have to add on a dummy URL and remove it
after the UrlEncode as well.
Anyway, if there is an object function somewhere that
already does this, I would love to hear about it.
Thanks
David
I need to take some values and place them in a string in
the format of a querystring.
Lets say I have:
string State = "ACT";
string SearchString = "Tax";
int MinRelevance = 50;
I want to create the string:
"?State=ACT&SearchString=Tax&MinRelevance=50"
This will then be placed on the end of the relevant URL,
and placed in an anchor tag on the resulting page, so the
user can click on that link.
Now in an ideal world, I would be able to do:
System.Web.QueryString x = new System.Web.QueryString();
x.Add("State", State);
x.Add("SearchString", SearchString);
x.Add("MinRelevance", MinRelevance);
return (x.ToString());
At the moment, I am looking at writing my own function to
do this. It will take a namevaluecollection, and iterate
through those, creating the querystring. Then I would
have to use System.Web.HttpUtility.UrlEncode. I would
assume I will have to add on a dummy URL and remove it
after the UrlEncode as well.
Anyway, if there is an object function somewhere that
already does this, I would love to hear about it.
Thanks
David