asp:CheckBox has no Value attribute - Help !!!

  • Thread starter Thread starter Fresh Air Rider
  • Start date Start date
F

Fresh Air Rider

I was extremely surprised to notice that the <asp:CheckBox> control
does not appear to have a "Value" attribute like it's HTML equivalent
does.

There are many occasions when you would want the value associated with
the checkbox to be different to the Text displayed.

ie
Value = ProductID
Text = Product description

The <asp:CheckBox> will not even allow me to set it's ID attribute
dynamically

ie ID="<%#DataBinder.Eval(Container.DataItem,"ProdID")%>"

Does anyone know how to overcome this shortfall in Microsoft's .Net
system ?

I'm sure that I'm not the only one to suffer the consequencies of this
omission.

Thanks
John
 
Hi FreshAirRider,

I really cannot understand why you need the value on a checkbox on the
serverside.

This kind of information is normally saved in the session information.

By the way, there is no HTML checkbox, there is an Input control with has
the type=checkbox. HTML Input control has all the attributes in every type
from Input, if it is usable or not usable.

I think that it is not right to the ones from Microsoft who made this to
call this a "shortfall", nowhere is written that what you write is
necessary.

Maybe you think it is something that everybody need and than I think you
could make your own serverside checkbox control for this and sell that to
the market.

Just my thought,

Cor
 
I really cannot understand why you need the value on a checkbox on the
serverside.

I agree with the OP. There are many times when a checked checkbox should
send a value to the server that is different than the text caption of the
checkbox. A checkbox is no different from any other form control, in that
it has (or in the case of a web form checkbox "should" have the ability to
send form data to the server.
This kind of information is normally saved in the session information.

Normally? According to whom? Form data that is submitted is handled in
many different ways but one thing that is true is that it is always sent to
the server. The developer can do many different things with it from there
(email it somewhere else, store it in a database, use the data for more
processing to take place, store it in a cookie, store it in session, etc.).
By the way, there is no HTML checkbox, there is an Input control with has
the type=checkbox. HTML Input control has all the attributes in every type
from Input, if it is usable or not usable.

I think the OP gets that. Never-the-less, it is still very common to refer
to it as an HTML Checkbox.
I think that it is not right to the ones from Microsoft who made this to
call this a "shortfall", nowhere is written that what you write is
necessary.

Necessary, no. You are correct, in that, we don't *need* a value property,
but it would certainly enhance the web form checkbox for it to have one.
Maybe you think it is something that everybody need and than I think you
could make your own serverside checkbox control for this and sell that to
the market.

There is so much in the Framework that only a small percentage of developers
would ever use. Something like adding a value property to the web form
checkbox does seem to me to be an oversight and a shortfall. I think many
people would see the "value" of having a "value" property.
 
I agree. For now, you can use a standard HTML checkbox and mark it as "Run
as server control". Then, you'll be able to program it server side as well
as use its value property as you are used to.
 
Hi Scott,

I was triggered by that "shortfall" and than I alway try to anwer in the
same style.

That is all.

:-))

Cor
 
Back
Top