I am trying to retrieve one of the database field from sql 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", "&");
The problem is not the whitespace, but the ampersand. URLEncode it: %26
, in your literal.Text
.
You can use Reqex to remove extra space
Regex.Replace(YOURTEXT, @"\\s+", "")
This will remove any space within text.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.