By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,728 Members | 2,414 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,728 IT Pros & Developers. It's quick & easy.

properties of Radio buttons on a page

P: n/a

I have a page that has a number of radio buttons that will be displayed
to different access levels of a user who logs in to my website.

For instance, if there are a dozen buttons, user1 will see all twelve.
User2 would see buttons 1-3,10-12 and NOT any others, and so on.

Since there are several buttons on the page (each one would run a report
for them), is there a way to - in an onclick event for each of the
buttons - to programatically go thru and bold the font of the
description of the button, and un-bold the rest of them? Doing this in
order to make it more apparent as to which report they've just run.

I know that I could do a bunch of if statements to do this, but would
prefer to do it in a loop.

The radio buttons are independent of each other, as this code is being
inserted into a page that already had a few of them on it previously
(the newer buttons are the newer reports).

Anyone know how to do this, or perhaps have a better way to do it?

Appreciate any suggestions or advice.

Thanks,

BC
May 23 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
You have two totally independent questions here, and a confusing statement:
1) how to display only relevant content (radio buttons) depending on the user
2) how to enbold one control of the list on postback
3) list of radio buttons that are independent - why use radio buttons?

One way to acconplish the first two would be:
1)
- create a bitmask based on user Role, say 1 - public, 2 - power user, 4 -
admin
- associate eash radio button with relevant value, say btn1 - 7, btn2 - 6,
btn3 - 4
- loop through your list of buttons and only display those that match
current user, for example:
int userRoleMask = 3; // (power user + public)
foreach (object btn in myBtnList) // any structure for myBtn will do, just
ensure it implements RoleMask property, and the actual RadioButton
{
btn.RadioButton.Visible = btn.RoleMask & userRoleMask; // in VB your would
use And instead of &
}

2) I would create a private property on the page to store the last bold
label, and then on postback check if new one needs to be bold then unbold the
old one and store the newly bold one instead. Something like:
private string boldID
{
get{return this.ViewState["BoldID"] as string;}
set{this.ViewState["BoldID"] = value;}
}

HTH

"Blasting Cap" wrote:
>
I have a page that has a number of radio buttons that will be displayed
to different access levels of a user who logs in to my website.

For instance, if there are a dozen buttons, user1 will see all twelve.
User2 would see buttons 1-3,10-12 and NOT any others, and so on.

Since there are several buttons on the page (each one would run a report
for them), is there a way to - in an onclick event for each of the
buttons - to programatically go thru and bold the font of the
description of the button, and un-bold the rest of them? Doing this in
order to make it more apparent as to which report they've just run.

I know that I could do a bunch of if statements to do this, but would
prefer to do it in a loop.

The radio buttons are independent of each other, as this code is being
inserted into a page that already had a few of them on it previously
(the newer buttons are the newer reports).

Anyone know how to do this, or perhaps have a better way to do it?

Appreciate any suggestions or advice.

Thanks,

BC
May 23 '07 #2

P: n/a
Sergey - Thank you for the help. I'll try them later on today.

As to your third question - why use radio buttons - because that's what
was originally done on the page, and since I've been maintaining the
application, it has been more development-time efficient to simply "add
a new radio button" than it has been to re-do that part of the page. Is
there a better way to do what I'm wanting to do than by using radio buttons?

BC
Sergey Poberezovskiy wrote:
You have two totally independent questions here, and a confusing statement:
1) how to display only relevant content (radio buttons) depending on the user
2) how to enbold one control of the list on postback
3) list of radio buttons that are independent - why use radio buttons?

One way to acconplish the first two would be:
1)
- create a bitmask based on user Role, say 1 - public, 2 - power user, 4 -
admin
- associate eash radio button with relevant value, say btn1 - 7, btn2 - 6,
btn3 - 4
- loop through your list of buttons and only display those that match
current user, for example:
int userRoleMask = 3; // (power user + public)
foreach (object btn in myBtnList) // any structure for myBtn will do, just
ensure it implements RoleMask property, and the actual RadioButton
{
btn.RadioButton.Visible = btn.RoleMask & userRoleMask; // in VB your would
use And instead of &
}

2) I would create a private property on the page to store the last bold
label, and then on postback check if new one needs to be bold then unbold the
old one and store the newly bold one instead. Something like:
private string boldID
{
get{return this.ViewState["BoldID"] as string;}
set{this.ViewState["BoldID"] = value;}
}

HTH

"Blasting Cap" wrote:
>I have a page that has a number of radio buttons that will be displayed
to different access levels of a user who logs in to my website.

For instance, if there are a dozen buttons, user1 will see all twelve.
User2 would see buttons 1-3,10-12 and NOT any others, and so on.

Since there are several buttons on the page (each one would run a report
for them), is there a way to - in an onclick event for each of the
buttons - to programatically go thru and bold the font of the
description of the button, and un-bold the rest of them? Doing this in
order to make it more apparent as to which report they've just run.

I know that I could do a bunch of if statements to do this, but would
prefer to do it in a loop.

The radio buttons are independent of each other, as this code is being
inserted into a page that already had a few of them on it previously
(the newer buttons are the newer reports).

Anyone know how to do this, or perhaps have a better way to do it?

Appreciate any suggestions or advice.

Thanks,

BC
May 24 '07 #3

P: n/a
Before you answer the question (about is there a better way to do what
I'm doing...) - some info:

This is a web application, dotnet framework 2.0, VS 2005.

When I come in to the page, I have a username and a "level" assigned to
the user thru a session variable or a cookie. There are 8 levels, each
of them show a different combination of the same reports. This level
gets passed in to a sql query that determines what type of data is
returned in those queries.

For instance - a user at level 6 would see reports 1,2,3,7,9,12

User at level 5 would see reports 2,4,7,9,11,12

User at level 3 would see reports 5 & 6

Ideally, I'd like for the selection list of the reports to have a
similar "look" for each user - meaning that if he saw 12 reports, they'd
be 12 contiguous ones, if he saw 6 of them, they'd look like they were
the list he would see (i.e. no "gaps" between the reports for the ones
omitted for the user who saw 6 reports versus 12.

Thanks,

BC

Sergey Poberezovskiy wrote:
You have two totally independent questions here, and a confusing statement:
1) how to display only relevant content (radio buttons) depending on the user
2) how to enbold one control of the list on postback
3) list of radio buttons that are independent - why use radio buttons?

One way to acconplish the first two would be:
1)
- create a bitmask based on user Role, say 1 - public, 2 - power user, 4 -
admin
- associate eash radio button with relevant value, say btn1 - 7, btn2 - 6,
btn3 - 4
- loop through your list of buttons and only display those that match
current user, for example:
int userRoleMask = 3; // (power user + public)
foreach (object btn in myBtnList) // any structure for myBtn will do, just
ensure it implements RoleMask property, and the actual RadioButton
{
btn.RadioButton.Visible = btn.RoleMask & userRoleMask; // in VB your would
use And instead of &
}

2) I would create a private property on the page to store the last bold
label, and then on postback check if new one needs to be bold then unbold the
old one and store the newly bold one instead. Something like:
private string boldID
{
get{return this.ViewState["BoldID"] as string;}
set{this.ViewState["BoldID"] = value;}
}

HTH

"Blasting Cap" wrote:
>I have a page that has a number of radio buttons that will be displayed
to different access levels of a user who logs in to my website.

For instance, if there are a dozen buttons, user1 will see all twelve.
User2 would see buttons 1-3,10-12 and NOT any others, and so on.

Since there are several buttons on the page (each one would run a report
for them), is there a way to - in an onclick event for each of the
buttons - to programatically go thru and bold the font of the
description of the button, and un-bold the rest of them? Doing this in
order to make it more apparent as to which report they've just run.

I know that I could do a bunch of if statements to do this, but would
prefer to do it in a loop.

The radio buttons are independent of each other, as this code is being
inserted into a page that already had a few of them on it previously
(the newer buttons are the newer reports).

Anyone know how to do this, or perhaps have a better way to do it?

Appreciate any suggestions or advice.

Thanks,

BC
May 24 '07 #4

P: n/a
If you drive your report list from the database, you could use Repeater and
place your option button inside ItemTemplate (do not forget to set GroupName
for your RadioButton) - this way you will always have them running
continuously.
"Blasting Cap" wrote:
Before you answer the question (about is there a better way to do what
I'm doing...) - some info:

This is a web application, dotnet framework 2.0, VS 2005.

When I come in to the page, I have a username and a "level" assigned to
the user thru a session variable or a cookie. There are 8 levels, each
of them show a different combination of the same reports. This level
gets passed in to a sql query that determines what type of data is
returned in those queries.

For instance - a user at level 6 would see reports 1,2,3,7,9,12

User at level 5 would see reports 2,4,7,9,11,12

User at level 3 would see reports 5 & 6

Ideally, I'd like for the selection list of the reports to have a
similar "look" for each user - meaning that if he saw 12 reports, they'd
be 12 contiguous ones, if he saw 6 of them, they'd look like they were
the list he would see (i.e. no "gaps" between the reports for the ones
omitted for the user who saw 6 reports versus 12.

Thanks,

BC

Sergey Poberezovskiy wrote:
You have two totally independent questions here, and a confusing statement:
1) how to display only relevant content (radio buttons) depending on the user
2) how to enbold one control of the list on postback
3) list of radio buttons that are independent - why use radio buttons?

One way to acconplish the first two would be:
1)
- create a bitmask based on user Role, say 1 - public, 2 - power user, 4 -
admin
- associate eash radio button with relevant value, say btn1 - 7, btn2 - 6,
btn3 - 4
- loop through your list of buttons and only display those that match
current user, for example:
int userRoleMask = 3; // (power user + public)
foreach (object btn in myBtnList) // any structure for myBtn will do, just
ensure it implements RoleMask property, and the actual RadioButton
{
btn.RadioButton.Visible = btn.RoleMask & userRoleMask; // in VB your would
use And instead of &
}

2) I would create a private property on the page to store the last bold
label, and then on postback check if new one needs to be bold then unbold the
old one and store the newly bold one instead. Something like:
private string boldID
{
get{return this.ViewState["BoldID"] as string;}
set{this.ViewState["BoldID"] = value;}
}

HTH

"Blasting Cap" wrote:
I have a page that has a number of radio buttons that will be displayed
to different access levels of a user who logs in to my website.

For instance, if there are a dozen buttons, user1 will see all twelve.
User2 would see buttons 1-3,10-12 and NOT any others, and so on.

Since there are several buttons on the page (each one would run a report
for them), is there a way to - in an onclick event for each of the
buttons - to programatically go thru and bold the font of the
description of the button, and un-bold the rest of them? Doing this in
order to make it more apparent as to which report they've just run.

I know that I could do a bunch of if statements to do this, but would
prefer to do it in a loop.

The radio buttons are independent of each other, as this code is being
inserted into a page that already had a few of them on it previously
(the newer buttons are the newer reports).

Anyone know how to do this, or perhaps have a better way to do it?

Appreciate any suggestions or advice.

Thanks,

BC
May 24 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.