html or web control question

A

astro

I want to have 2 mutually exclusive checkboxes on a webform. I do not want
to post back to server for this to happen.

Last week I built this using javascript with each ctrl calling a javascript
function on the page that automatically unchecked it's mate. I ran into
problems with this approach when I needed to pass the list of checked
checkboxes to the next webform for processing via some vb.net code.

Is there a way to load an arraylist or hashtable referencing these html
controls? Obviously this would be done on the server. ... I just don't know
how to reference these checkboxes from vb.net code on the server (or
otherwise) since they are html controls...

Is dumping this information into the url via javascript the only way?

If these checkboxes where webctrl checkboxes I could write code to load them
into a hashtable and pass them back via a session variable (demostrated in
Mark Ridgeway's book - VB.net developer's handbook)....but based on my small
understanding of things this would entail having each check cause a postback
to the server for unchecking it's mate (which seems like a really big waste
of time)....

Feedback appreciated...
 
T

Trevor Benedict R

Use the Web Control. Every control has a Unique ClientID. If you have 2
checkboxes then you can attach Javascript code to each of the Checkboxes to
uncheck the other. All this can be done on the server side to execute client
side code. So when you do the actual postback you have the code.

Another method is to use HTML controls and add the Runat="Server" attribute
and write client side code, but not sure why you would want this in this
scenario.

Regards,

Trevor Benedict R
MCSD
 
L

Laurent Bugnion

Hi,
I want to have 2 mutually exclusive checkboxes on a webform. I do not want
to post back to server for this to happen.

Aren't two mutually exclusive checkboxes, per definition, radio buttons?

Laurent
 
L

Laurent Bugnion

Hi,
yes - but i like the look of checkboxes....

-)

*L* That's an funny, though very much anti-ergonomic reason ;-)

I won't try to make you change your mind.

If you give more details about the way you create the controls, I can
show you how to have client-side JavaScript code to make them mutually
exclusive.

HTH,
Laurent
 
A

Alan Silver

yes - but i like the look of checkboxes....
*L* That's an funny, though very much anti-ergonomic reason ;-)

I won't try to make you change your mind.

I will, as would anyone who has read up anything about user interfaces.

Changing the behaviour of any standard control is a very bad idea. Users
have come to expect certain behaviours from certain controls. If you
change this, you will confuse them. The chances are that they will not
bother fighting with your site, they will just give up and go elsewhere.

This is well researched and well known. It's not a piece of folklore.
You are running a serious risk of losing visitors for the sake of some
personal (and highly irregular) whim. What's the point?

End of rant ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top