Reputation: 1435
I am trying to retrieve one of the database field fromsql server 2008
with the following code,In the database the data field is named as OBGST & GYNAECOLOGY
which has a ampersand
in it.
Now when i am retrieving in asp.net only the first text before ampersand is been displayed as
OBGST
,but the actual result should be OBGST & GYNAECOLOGY
.
I have tried the following code but still didn't get rid of this issue.
literal.Text = "<script>window.open('UploadFiles.aspx?dept="+deptname+"&hosno=" + hosno + "&visitno=" + visitno + "','_blank')</script>";
txtdept.Text = Request.QueryString["dept"].ToString().Replace("%20&%20", "&");
Upvotes: 0
Views: 348
Reputation: 33511
The problem is not the whitespace, but the ampersand. URLEncode it: %26
, in your literal.Text
.
Upvotes: 2
Reputation: 2573
You can use Reqex to remove extra space
Regex.Replace(YOURTEXT, @"\s+", "")
This will remove any space within text.
Upvotes: 0