473,569 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to add " " to list item text

I am try to set the text of the drop down list item as

ListItem li = new ListItem();
li.Text = " "+"MyVal ue";

myDropDown.Item s.Add("li);

The intent is to add a spacing in front of the text. Its not doing what I am
trying to do. The text shows up as "&ampMyValu e"

How can this be accomplished?
Nov 17 '05 #1
5 11152
Thanks Justin,
I tried that. It truncates the blank spaces at the start. In regular ASP
apps I was able to do..

<option>&nbsp;& nbsp;MyValue

I am trying to do the same thing with DropdownList control
"S. Justin Gengo" <sj*****@aboutf ortunate.com> wrote in message
news:um******** ******@tk2msftn gp13.phx.gbl...
Naveen,

Drop down lists don't use the same encoding as regular html on the page.

Just add a regular " " space.

Sincerely,
--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Naveen K Kohli" <na*********@ho tmail.com> wrote in message
news:ON******** ******@TK2MSFTN GP12.phx.gbl...
I am try to set the text of the drop down list item as

ListItem li = new ListItem();
li.Text = "&nbsp;"+"MyVal ue";

myDropDown.Item s.Add("li);

The intent is to add a spacing in front of the text. Its not doing what
I am
trying to do. The text shows up as "&ampMyValu e"

How can this be accomplished?


Nov 17 '05 #2
What I think the issue is is that you are using the "+" to
add both strings..i think you must use the & char.

Well in VB.Net in C# your right on the money I think..you
use the "+"..but you didn't specify any language

ListItem li = new ListItem();
li.Text = "&nbsp;" & "MyValue";

myDropDown.Item s.Add("li");
-----Original Message-----
Thanks Justin,
I tried that. It truncates the blank spaces at the start. In regular ASPapps I was able to do..

<option> MyValue

I am trying to do the same thing with DropdownList control
"S. Justin Gengo" <sj*****@aboutf ortunate.com> wrote in messagenews:um******* *******@tk2msft ngp13.phx.gbl.. .
Naveen,

Drop down lists don't use the same encoding as regular html on the page.
Just add a regular " " space.

Sincerely,
--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Naveen K Kohli" <na*********@ho tmail.com> wrote in message news:ON******** ******@TK2MSFTN GP12.phx.gbl...
> I am try to set the text of the drop down list item as
>
> ListItem li = new ListItem();
> li.Text = " "+"MyValue" ;
>
> myDropDown.Item s.Add("li);
>
> The intent is to add a spacing in front of the text.
Its not doing whatI
am
> trying to do. The text shows up as "&MyValue"
>
> How can this be accomplished?
>
>


.

Nov 17 '05 #3
I think choice of language was clear. I don't think that VB uses ";" at the
end of statement. Thats not the point.
ListItem truncates the leading spaces. And if you have any HTML decoded
string, it will encode it and display as "&ampndp;". The solution to this
issue can be found at floowing link.,

http://www.netomatix.com/IndentDropdownList.aspx

Naveen

"Tyrone" <t_*******@hotm ail.com> wrote in message
news:08******** *************** *****@phx.gbl.. .
What I think the issue is is that you are using the "+" to
add both strings..i think you must use the & char.

Well in VB.Net in C# your right on the money I think..you
use the "+"..but you didn't specify any language

ListItem li = new ListItem();
li.Text = "&nbsp;" & "MyValue";

myDropDown.Item s.Add("li");
-----Original Message-----
Thanks Justin,
I tried that. It truncates the blank spaces at the start.

In regular ASP
apps I was able to do..

<option> MyValue

I am trying to do the same thing with DropdownList control
"S. Justin Gengo" <sj*****@aboutf ortunate.com> wrote in

message
news:um******* *******@tk2msft ngp13.phx.gbl.. .
Naveen,

Drop down lists don't use the same encoding as regular html on the page.
Just add a regular " " space.

Sincerely,
--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Naveen K Kohli" <na*********@ho tmail.com> wrote in message news:ON******** ******@TK2MSFTN GP12.phx.gbl...
> I am try to set the text of the drop down list item as
>
> ListItem li = new ListItem();
> li.Text = " "+"MyValue" ;
>
> myDropDown.Item s.Add("li);
>
> The intent is to add a spacing in front of the text.

Its not doing what
I
am
> trying to do. The text shows up as "&MyValue"
>
> How can this be accomplished?
>
>

.

Nov 17 '05 #4
The code below should help you out.
--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_auth or_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_autho r_plug>
----------------------------------------------

<%@ Page Language="VB" Debug="true" %>
<script language=VB runat=server>

Sub Page_Load(Sende r As Object, E As EventArgs)

Dim Padding As String
Dim writer As New System.IO.Strin gWriter()
Dim DecodedString As String

Padding = "&nbsp;&nbs p;"
Server.HtmlDeco de(Padding, writer)
Padding = writer.ToString ()

myDropDownList2 .Items.Add(Padd ing & " MVP's")

Padding = "&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;"
Server.HtmlDeco de(Padding, writer)
Padding = writer.ToString ()

myDropDownList2 .Items.Add(Padd ing & " MVP's")

myDropDownList2 .Items.Add("MVP 's" & Padding & "Do Their best")

End Sub

</script>
<html>
<head><title>Pa dding DropListBox</title></head>
<body><form fred runat="server"> <asp:dropdownli st id="MyDropDownL ist2"
runat="server"/></form></body>
</html>

Nov 17 '05 #5
John,
I did try this before posting the code. Nothing seemed to work. &nbsp; did
not show up as spaces.

Thanks.

"John Timney (Microsoft MVP)" <ti*****@despam med.com> wrote in message
news:eu******** ******@TK2MSFTN GP10.phx.gbl...
The code below should help you out.
--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_auth or_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_autho r_plug>
----------------------------------------------

<%@ Page Language="VB" Debug="true" %>
<script language=VB runat=server>

Sub Page_Load(Sende r As Object, E As EventArgs)

Dim Padding As String
Dim writer As New System.IO.Strin gWriter()
Dim DecodedString As String

Padding = "&nbsp;&nbs p;"
Server.HtmlDeco de(Padding, writer)
Padding = writer.ToString ()

myDropDownList2 .Items.Add(Padd ing & " MVP's")

Padding = "&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;"
Server.HtmlDeco de(Padding, writer)
Padding = writer.ToString ()

myDropDownList2 .Items.Add(Padd ing & " MVP's")

myDropDownList2 .Items.Add("MVP 's" & Padding & "Do Their best")

End Sub

</script>
<html>
<head><title>Pa dding DropListBox</title></head>
<body><form fred runat="server"> <asp:dropdownli st id="MyDropDownL ist2"
runat="server"/></form></body>
</html>

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
5650
by: ian justice | last post by:
Before i post actual code, as i need a speedyish reply. Can i first ask if anyone knows off the top of their head, if there is a likely obvious cause to the following problem. For the moment i've reduced my form request to a simple text string entry, instead of my desired optional parameters. As i have been stuck with a single unfathomable...
13
6339
by: rbronson1976 | last post by:
Hi all, I have a very simple page that Firefox has problems with: www.absolutejava.com/testing.htm First of all, this page seems to be perfectly valid XHTML Strict. Both the W3C validator as well as Page Valet indicate it is valid. The page is being served with the proper MIME type of "application/xhtml+xml". Unfortunately, Firefox...
12
47556
by: Robert Mark Bram | last post by:
Hi All, I am using the following trim function: function trim (str) { return str.replace(/^\s*/g, '').replace(/\s*$/g, ''); } The problem is that this doesn't trim instances of the "&nbsp;" char - the non breaking space. Can this be represented in a grep statement at
0
2554
by: K B | last post by:
Hi again, I have a gridview, when I get the selecteditem.cells for a column, if the database column is Null or Empty, and I assign that to my web form text control, the control reads "&nbsp;" instead of a blank. Never had this happen before, but I am now using Asp.Net 2.0. Ideas please?
7
49856
by: 一首诗 | last post by:
Is there any simple way to solve this problem?
7
4600
by: John Nagle | last post by:
I've been parsing existing HTML with BeautifulSoup, and occasionally hit content which has something like "Design & Advertising", that is, an "&" instead of an "&amp;". Is there some way I can get BeautifulSoup to clean those up? There are various parsing options related to "&" handling, but none of them seem to do quite the right thing. If I...
1
3195
by: zaidalin79 | last post by:
I am in a JavaScript class, and we have to get all of our code to validate at the w3c website... Here is my code, it does what I want it to do which is require the user to enter the name and either the address of the email address, but when I try to validate it through w3c, I get the following errors... Can anyone help? <!DOCTYPE html...
2
4288
by: bips2008 | last post by:
The code seems to work fine in other browser but in IE it throws this error. This is very urgent for me and any help would be greatly appreciated For your convienence i have posted the code for the file. The portion that is not working is the star rating part <?php session_start(); include_once('includes/host_conf.php');...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8132
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7678
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6286
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5222
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.