3

I am binding to a DropDownList as follows;

Sub bindGalleries(ByVal catID As Integer)
    ddlGalleries.DataSource = Galleries.GetGalleries(catID)
    ddlGalleries.DataTextField = "GalleryName"
    ddlGalleries.DataValueField = "GalleryID"
    ddlGalleries.DataBind()
End Sub

One of the items in the list is: 'Kültür & Sanat', which is displayed just right in the dropdownlist. But when I look at the source of the page, it is: Kültür & Sanat

How can I get the source to be exactly the same as the original string?

Note: my meta tag is: in master page..

Eric J.
  • 147,927
  • 63
  • 340
  • 553
Subliminal Hash
  • 13,614
  • 20
  • 73
  • 104

4 Answers4

2

This should give you what you need:

Server.HtmlDecode("Kültür & Sanat");

Write a method to "sanitize" the items in the DDL and store them in an array. Then just bind to the array.

You can populate the DDL in a similar fashion.

IrishChieftain
  • 15,108
  • 7
  • 50
  • 91
0

You may be able to use backslashes to escape

Prince
  • 199
  • 1
  • 3
  • 14
0

The reason why you see those characters is because those characters are being htmlencoded upon saving into your source.

i.e.

YourSource = server.htmlEncode(value) 

or

YourSource = server.urlEncode

You can save it to its original form by using server.htmlDecode or by omitting the server.htmlEncode.

AlexB
  • 7,302
  • 12
  • 56
  • 74
Pinoy2015
  • 1,429
  • 15
  • 29
  • No, actually the values are saved just fine, when rendered to the page as html, they look fine too. But when I look at the source they are encoded. I am getting the value with javascript and sending it to a http handler. By the time it reaches the handler, the characters are now little question marks in diamond shapes. So somehow, either I need to decode them during binding? or how do I decode the diamond shapes when they reach to my ashx file? – Subliminal Hash Jul 05 '12 at 01:39
  • Try using jquery to retrieve the value of the dropdown like the method shown in the link? http://stackoverflow.com/questions/1147359/how-to-decode-html-entities-using-jquery – Pinoy2015 Jul 05 '12 at 01:58
  • Do you know how can I prevent the page to be rendered like that in the first place? – Subliminal Hash Jul 05 '12 at 02:03
0

Try to put the proper charset in the heading portion of your page.

Example:

<meta http-equiv="Content-Type" content="text/html; charset=utf-16"/>
Pinoy2015
  • 1,429
  • 15
  • 29