473,507 Members | 13,597 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Which button event would work the best to disable the button.

I would like to disable a button on the form if the user is not authorized to
use it.

I've created a custom button and would like for each button to know if it
should be enabled or disabled based on another class that would contain the
users authority levels.

I know I can use the on form load event, but I rather test to see if the
user has access to the button during the buttons OnPaint event? If they
don't have access, I'd like to disable the button. So should I use the
OnPaint event for the button, or is there an event that would be more
appropriate.
Nov 17 '05 #1
5 1684
Button has Enabled property. If it is set to false, it is not drawn and user
can not click on it.
Nov 17 '05 #2
I know that, but when would be a good time to set the buttons enable property
to false if the user doesn't have authority. So should I set it to false
during the button paint event, or some other event.

"Lebesgue" wrote:
Button has Enabled property. If it is set to false, it is not drawn and user
can not click on it.

Nov 17 '05 #3
I know that, but when would be a good time to set the buttons enable property to false if the user doesn't have authority. So should I set it to false
during the button paint event, or some other event.


You should set it to false once, whenever you want. I don't find Paint event
very suitable, try to set it when the conditions deteminig if it should be
available change. It will stay false until you set it to true;
Nov 17 '05 #4
do it on Page_Load()

--
info@donotspam dowhileloop.com
http://www.dowhileloop.com web development
http://publicjoe.dowhileloop.com -- C# Tutorials
"Vern" <Ve**@discussions.microsoft.com> wrote in message
news:6E**********************************@microsof t.com...
I know that, but when would be a good time to set the buttons enable property to false if the user doesn't have authority. So should I set it to false
during the button paint event, or some other event.

"Lebesgue" wrote:
Button has Enabled property. If it is set to false, it is not drawn and user can not click on it.

Nov 17 '05 #5
How about if I do it during the buttons constructor as follows:

public class ButtonExit : Button
{
public ButtonExit() : base()
{
// If user doesn't have enough authority, then disable this button.
if (!Authorized(ButtonSecurityLevel))
{
this.Enabled = false ;
}
}
.....
}
"Landi" wrote:
do it on Page_Load()

--
info@donotspam dowhileloop.com
http://www.dowhileloop.com web development
http://publicjoe.dowhileloop.com -- C# Tutorials
"Vern" <Ve**@discussions.microsoft.com> wrote in message
news:6E**********************************@microsof t.com...
I know that, but when would be a good time to set the buttons enable

property
to false if the user doesn't have authority. So should I set it to false
during the button paint event, or some other event.

"Lebesgue" wrote:
Button has Enabled property. If it is set to false, it is not drawn and user can not click on it.


Nov 17 '05 #6

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

Similar topics

3
1143
by: MoeJoe | last post by:
I have an asp.net app that updates SQL server and AD, I wanted to disable the "SAVE" button when its clicked until all data are saved. so I did the followin in the Page_Loa If Page.IsPostBack =...
1
2897
by: Bin Song, MCP | last post by:
Hi all I got a strange problem In my webform, I have a server-side Button "btnDisable" to save some data and enable or disable all other fields in this form based on the data. The logic is: on...
3
3142
by: Jeff | last post by:
I have a payment form with a submit button. A large percentage of users double-click the submit button thus submitting their payment information twice. I would like to use javascript to disable...
16
3404
by: Barry Gilmore | last post by:
Is there a way to disable a button after it is clicked? I am trying to avoid having someone click on it twice while they wait for it to process. Thank you!
4
18623
by: Patrick Flaherty | last post by:
Hi, Experienced programmer but new to PHP. Moreover I'm to use PHP with Xoops on top (this adds object orientation?). I don't seem to find a xoops Usenet group? Whatever the case (and...
2
7697
by: bay_dar | last post by:
Hi, I have an internal ASP.NET application that I'm are using to send e-mails out based on a single milepost or milepost range entered. I'm trying to do two things when a user clicks on the...
15
3592
by: mc | last post by:
I'm writing an app for managing Task Lists, I'm trying to add some controls to a form that I can use to link tasks, my original intention was to: - Add two list boxes, one listing "all Tasks"...
8
2011
by: Richard Maher | last post by:
Hi, I am in a mouseup event for button A and I'd like to disable=false button B before starting some work. Is there anyway that an event for button B can then fire before my event processing for...
2
2544
by: Gugale at Lincoln | last post by:
Hi, I am creating a user control which has a radio button and few other controls. I would like the user control to behave like a radio button, in the sense when added to a container radio button...
0
7314
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7372
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...
0
7482
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...
0
5623
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,...
1
5041
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1540
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 ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.