Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > <asp:ListItem> in v2

Reply
Thread Tools

<asp:ListItem> in v2

 
 
Mark Rae
Guest
Posts: n/a
 
      01-27-2006
Hi,

Has the <aspropDownList> - <asp:ListItem> functionality changed in v2? In
v1.1, the following works as expected:

<aspropDownList ID="cmbStatus" Runat=server EnableViewState=False>
<asp:ListItem Value=0>&nbsp;</asp:ListItem>
<asp:ListItem Value=1>Awaiting</asp:ListItem>
<asp:ListItem Value=2>Current</asp:ListItem>
<asp:ListItem Value=3>Terminated</asp:ListItem>
</aspropDownList>

i.e. three options with a blank option at the top.

However, in v2, the first option (i.e. the one which should be blank)
displays with a zero instead of the non-breaking space - when I do a View
Source, I can see that &nbsp; has been replaced by 0.

Is this normal?

Mark


 
Reply With Quote
 
 
 
 
S. Justin Gengo [MCP]
Guest
Posts: n/a
 
      01-27-2006
Mark,

Spaces get trimmed off of drop down lists autmatically. So the list must
think it's completely empty and then substitutes the value.

Yes, I think this is by design. There is a way to encode a space so it shows
up in a drop down list. I have a StringUtilities object that I give away on
my website and one of the routines in it is a way to pad encode spaces so
that a drop down list may be padded.

Here's the routine:

Private Function Pad(ByVal server As HttpServerUtility, ByVal numberOfSpaces
As Int32) As String
Try
Dim Spaces As String
For items As Int32 = 1 To numberOfSpaces
Spaces &= "&nbsp;"
Next
Return server.HtmlDecode(Spaces)
Catch ex As Exception
Throw ex
End Try

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Mark Rae" <> wrote in message
news:...
> Hi,
>
> Has the <aspropDownList> - <asp:ListItem> functionality changed in v2?
> In v1.1, the following works as expected:
>
> <aspropDownList ID="cmbStatus" Runat=server EnableViewState=False>
> <asp:ListItem Value=0>&nbsp;</asp:ListItem>
> <asp:ListItem Value=1>Awaiting</asp:ListItem>
> <asp:ListItem Value=2>Current</asp:ListItem>
> <asp:ListItem Value=3>Terminated</asp:ListItem>
> </aspropDownList>
>
> i.e. three options with a blank option at the top.
>
> However, in v2, the first option (i.e. the one which should be blank)
> displays with a zero instead of the non-breaking space - when I do a View
> Source, I can see that &nbsp; has been replaced by 0.
>
> Is this normal?
>
> Mark
>



 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      01-27-2006
"S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote in
message news:...

> Spaces get trimmed off of drop down lists autmatically.


Since when? They certainly didn't in v1.x

> So the list must think it's completely empty and then substitutes the
> value.


That makes no sense to me...

> Yes, I think this is by design.


How intensely irritating.

> There is a way to encode a space so it shows up in a drop down list.


Yeah, one line of code will do that...
<DropDownList>.Items.Insert(0, new ListItem("", "0"));

That's not what I'm talking about - I'm talking about creating the
DropDownList and its ListItems in the source, not the code behind...


 
Reply With Quote
 
S. Justin Gengo [MCP]
Guest
Posts: n/a
 
      01-27-2006
Mark,

In that case, did you fail to try the obvious?

<aspropDownList ID="Test" runat="server">

<asp:ListItem Value="0" Text=""></asp:ListItem>

<asp:ListItem Value="1" Text="One"></asp:ListItem>

</aspropDownList>



Works just fine.


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Mark Rae" <> wrote in message
news:...
> "S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote
> in message news:...
>
>> Spaces get trimmed off of drop down lists autmatically.

>
> Since when? They certainly didn't in v1.x
>
>> So the list must think it's completely empty and then substitutes the
>> value.

>
> That makes no sense to me...
>
>> Yes, I think this is by design.

>
> How intensely irritating.
>
>> There is a way to encode a space so it shows up in a drop down list.

>
> Yeah, one line of code will do that...
> <DropDownList>.Items.Insert(0, new ListItem("", "0"));
>
> That's not what I'm talking about - I'm talking about creating the
> DropDownList and its ListItems in the source, not the code behind...
>



 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      01-27-2006
"S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote in
message news:...

> Works just fine.


Not for me - still replaces the empty string with the zero...


 
Reply With Quote
 
S. Justin Gengo [MCP]
Guest
Posts: n/a
 
      01-27-2006
Then something is wrong with your install.

Did you take a close look at the code? I'm setting the text parameter of the
list item instead of putting the text between the list item tags.

I've tested it on three machines each running visual studio 2005 and tested
placing it out on a test website and it works on all.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Mark Rae" <> wrote in message
news:%...
> "S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote
> in message news:...
>
>> Works just fine.

>
> Not for me - still replaces the empty string with the zero...
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57