C# .NET - passing space as parameter to querystring

Asked By Joe Black on 24-May-10 09:14 AM
Hi,

I am searching for some values in database1 (form1)and taking the values and populating it on a form2.
The value may be null sometimes.
I am passing the values to querystring from form1 to form2.
when the column value in database is null iam taking it as empty.

how to pass if the parameter is space.

thnks

%20 is a space - Robbe Morris replied to Joe Black on 24-May-10 09:15 AM

You could also use Server.UrlEncode(querystring)
Om Prakash replied to Joe Black on 24-May-10 09:15 AM
Encode the querystring. Example:

String MyURL;
MyURL = "http://www.contoso.com/articles.aspx?title=" + Server.UrlEncode("ASP.NET Examples");
Response.Write("<a href=" + MyURL + "> ASP.NET Examples </a>");

More info:
http://msdn.microsoft.com/en-us/library/zttxte6w.aspx
Mash B replied to Joe Black on 24-May-10 09:18 AM
U can use instead

if (string.IsNullOrEmpty(Response.QueryString["id"]))
{
    return true;  // is empty or null
}
Phivos Stylianides replied to Joe Black on 24-May-10 09:20 AM
I would recommend to encode and decode the query strings contained in urls. This all characters will be represented with url safe characters. Here is an example:

Server.HtmlEncode("QueryStringContainingSpaces");
Server.HtmlDecode("EncodedQueryString");
Joe Black replied to Om Prakash on 24-May-10 09:27 AM

I am retrieving values from grid and storing into variables pcodestr1..
Suppose this pcodestr3 has a Null value in database, then Iam picking it up as empty('').
Now i want to send this empty ( which will be &nbsp;) as parameter in querystring to form2 and assign it to a field.
can u help me on this..

Response.Redirect(

"/Form2.aspx?Name=" + pcodestr1 + "&Code=" + pcodestr2 + "&Keyval=" + pcodestr3);

Joe Black replied to Robbe Morris on 24-May-10 09:29 AM
 

I am retrieving values from grid and storing into variables pcodestr1..
Suppose this pcodestr3 has a Null value in database, then Iam picking it up as empty('').
Now i want to send this empty ( which will be &nbsp;) as parameter in querystring to form2 and assign it to a field.
can u help me on this..

Response.Redirect(

"/Form2.aspx?Name=" + pcodestr1 + "&Code=" + pcodestr2 + "&Keyval=" + pcodestr3);

Super Man replied to Joe Black on 24-May-10 09:29 AM

Response.Redirect("default2.aspx?id=" + Server.UrlEncode(" "));
Server.UrlEncode and Server.UrlDecode - Robbe Morris replied to Joe Black on 24-May-10 09:33 AM
end of post