Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to set value of entity NBSP into a string?
Message
From
21/11/2006 10:23:46
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01169162
Message ID:
01171424
Views:
12
Dmitry,

I don't do Web Forms hardly at all (so I can't comment on the problem you're having with the nbsp unless I play around with it a bit myself) ... but what Alexandre is suggesting is not a "complicated route" ... in fact, you should always sub-class the base controls and use your sub-classes on your forms instead of the .NET base classes.

Just my 2 cents...

~~Bonnie



>Alexandre,
>
>I won't go this complicated route. If I don't find a simple solution to this "nbsp" problem, I will throw this code out of the project and will create a work around.
>
>Thank you very much for your help.
>
>>k so what is happening is that .net does a html encode that's why you see the & + amp + ; in your html, so for that to work you will need to deal with the html generation of the drompdownlist yourself, so you will need to create a class that inherits from the dropdownlist and then use that class on your pages.
>>
>>>The source code shows values as & + amp + ; + nbsp + ; + &. (I added those plus signs here otherwise UT does not show the entities). That is, .NET inserts the & amp to show the value as literal and, obviously, this is not what I want.
>>>
>>>>Dimitry I tested on plain HTML Code so if u saying that in the .net combo didn't work, did you try to do a right click view source on the hmlpage that was generated and see what html .net had generate?
>>>>
>>>>>Yes, but you are not replacing spaces with the string "nbsp" here, right? That is, try to create a string of empty spaces. Then replace the empty spaces with the "nbsp" and set the value to an HTML control. Unless I don't understand something, you will see literal "nbsp" strings.
>>>>>
>>>>>>Testing the HTML looks like it works fine
>>>>>>
>>>>>>this is the html code:
>>>>>>
>>>>>><select name="test"><option selected value="1">test spaces          10 spaces</option><option value="2">test spaces          10 NBSP</option></select>
>>>>>>
>>>>>>the 2nd option instead of spaces has 10 & nbsp; and it shows ok on the html dropdown list.
>>>>>>
>>>>>>>Alexandre,
>>>>>>>But it does not work exactly as you are saying. The reason I posted this question was I was trying your suggestion on the dropdownlist (last Friday). But the dropdownlist shows values of "nbsp" and not the space as we exact. That is when I try .Replace(" ","nbsp;") or .Replace(" "," ") the literal value is set in the dropdownlist.
>>>>>>>
>>>>>>>>Dimitry all depends on where you are using that, i.e. if you use that on a textbox.text then you will see the value and not the space, while if you use it on a dropdownlist item you will see the space and not the string, so as you can see all depends where you are using it.
>>>>>>>>
>>>>>>>>>I need to figure out how to set a value of the HTML entity NBSP ( Ampersand + NBSP + Semicolon) into a string so that the browser will interpret it as an HTML special character and not a literal character.
>>>>>>>>>
>>>>>>>>>For example, if I do
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>string mystreen = "&"+ "nbsp" + ";" ;
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>The browser will show this string literally. But this is NOT what I want.
>>>>>>>>>
>>>>>>>>>Thank you for any suggestions.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform