473,769 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Read Only Checkbox(list) ?

/..
Hi all,

I'm working on a report display page that currently uses 5
checkboxlists with a total of 86 items to display values from 5
different tables in an Access database.

The page works fine now. On presenting it to the users they pointed
out that their users could change the values in the checkboxes and
then print them out, ultimately documenting false information.

I use these controls entirely to display boolean values from query
lookups. How can I make the checkboxlists read only?

I tried putting a checkboxlist in a web-forms panel control, and
setting the panel to read-only, like in older versions of Visual
Basic. While the checkboxes that were checked did display, and all
were read only, they were "grayed out", very low contrast and hard to
read.

I imagine that this could be done by inheriting the control class and
adding methods or properties to it, but that is beyond what I've ever
done, esp. in dot.net -- I'm kinda new to the subject, if not to
programming.

This has to be a FAQ, but I've been searching the web and don't find
anything close to answering the question.

I work mostly in C# (in ASP/ADO.Net)

Thanks,
/ts

--

exec rm -r /bin/laden*

##--------------------------------------------------##
"We are stardust, we are golden,
And we've got to get ourselves back to the Garden"
Joni Mitchell
##--------------------------------------------------##
Nov 17 '05 #1
2 9208
Here's an option for you to use.

Put the below code into your page. Then called the javascript function
enableFormEleme nt on page load. Use the below function call:

enableFormEleme nt( <form element>, <Is the element editable (true/false)> )

That will allow you to make checkbox's, radio button, textboxs, textareas,
etc, ALL either editable or not.

Now don't say I never gave you anything!

Enjoy

Chaitanya Marvici

Code below:

----------------------------------------------------------------------------
------------------------------------------------------------------

function enableFormEleme nt( element, editable ) {

if( element.length && ( ( element.name + "" ) == "undefined" ) ) { //This is
used if a group of elements, all with the same name

for( var x = 0; x < element.length; x++ ) { //is sent to the function. It
will loop through and recursively

enableFormEleme nt( element[x], editable ); //call this function to correctly
turn the readonly stuff off/on.

}

} else {

if( ( element.type != "hidden" ) && ( element.type != "button" ) && (
element.type != "image") ) {

var focusStr = element.onfocus + "";

var clickStr = element.onclick + "";

var changeStr = element.onchang e + "";

var focusFunction, clickFunction, changeFunction;
focusStr = trim( focusStr.substr ing( focusStr.indexO f("{") + 1,
focusStr.lastIn dexOf("}") ) );

clickStr = trim( clickStr.substr ing( clickStr.indexO f("{") + 1,
clickStr.lastIn dexOf("}") ) );

if( element.type.in dexOf( "select" ) >= 0 ) {

changeStr = trim( changeStr.subst ring( changeStr.index Of("{") + 1,
changeStr.lastI ndexOf("}") ) );

}
if( ! editable ) {

if( ( browserType == IE ) || ( browserType == Nav6 ) ) { element.readonl y =
true; }
focusFunction = new Function( "e", "blurElemen t( this );\n" + focusStr )

clickFunction = new Function( "e", "blurElemen t( this );\n" + clickStr )
if( element.type == "radio" || element.type == "checkbox" ) {

element.checked Temp = element.checked ;

}
if( element.type.in dexOf( "select" ) >= 0 ) {

changeFunction = new Function( "e", "resetEleme nt( this );\n" + changeStr )

}

} else {

var strStart;
if( ( browserType == IE ) || ( browserType == Nav6 ) ) { element.readonl y =
false; }
strStart = focusStr.lastIn dexOf( "blurElemen t( this );" );

if( strStart != -1 ) { focusFunction = new Function( "e", focusStr.substr (
strStart + "blurElemen t( this );".length, focusStr.length ) ) }
strStart = clickStr.lastIn dexOf( "blurElemen t( this );" );

if( strStart != -1 ) { clickFunction = new Function( "e", clickStr.substr (
strStart + "blurElemen t( this );".length, clickStr.length ) ) }
if( element.type.in dexOf( "select" ) >= 0 ) {

strStart = changeStr.lastI ndexOf( "resetEleme nt( this );" );

if( strStart != -1 ) { changeFunction = new Function( "e",
changeStr.subst r( strStart + "resetEleme nt( this );".length,
changeStr.lengt h ) ) }

}

}
if( typeof( focusFunction ) != "undefined" ) { element.onfocus =
focusFunction; }

if( typeof( clickFunction ) != "undefined" ) { element.onclick =
clickFunction; }

if( element.type.in dexOf( "select" ) >= 0 ) {

if( typeof( changeFunction ) != "undefined" ) { element.onchang e =
changeFunction; }

}

} // End check for form element type

}

}

function enableElements( f ) {

var numOfElements = f.length

var setFocus = false;

var proxyMarker = "Proxy";

for ( e = 0; e < numOfElements; e++ ) {

var visibleElement = f.elements[e];

var valueElement = f.elements[e];

if ( visibleElement. type=="checkbox ") {

var visibleElementN ame = visibleElement. name;

if ( visibleElementN ame.indexOf(pro xyMarker) >= 0 ) { // if proxy checkbox

var valueElementNam e = visibleElementN ame.substring( 0,
visibleElementN ame.indexOf(pro xyMarker) );

valueElement = f.elements[ valueElementNam e ];

}

}

enableFormEleme nt( visibleElement, isElementEditab le( valueElement ) );

}

}

function blurElement( element ) {

if( element.type == "radio" || element.type == "checkbox" ) {

if( eval( "document." + element.form.na me + "." + element.name +
".length" ) ) {

for( var x = 0; x < eval( "document." + element.form.na me + "." +
element.name + ".length" ); x++ ) {

eval( "document." + element.form.na me + "." + element.name + "[" + x +
"].checked = " + "document." + element.form.na me + "." + element.name + "["
+ x + "].checkedTemp ? true : false;" );

}

} else {

element.checked = element.checked Temp ? true : false;

}

}
if( element.type.in dexOf( "select" ) >= -1 ) {

element.selectI ndexTemp = element.selecte dIndex;

}

element.blur();

}

function resetElement( element ) {

if( element.type.in dexOf( "select" ) >= -1 ) {

element.selecte dIndex = element.selectI ndexTemp;

}

}

"/.." <no*******@ix.n etcom.com> wrote in message
news:v0******** *************** *********@4ax.c om...
By Mon, 21 Jul 2003 18:06:43 -0700, "Steve C. Orr, MCSD"
<St***@Orr.ne t> decided to post
"Re: Read Only Checkbox(list) ?" to
microsoft.publi c.dotnet.framew ork.aspnet:
You might consider this is a bit of a hack, but how about changing the
background color of the page or panel so there is greater contrast with thegrayed out checkboxes? Simplicity sells.


Thanks for the suggestion,
but since it goes out to serious clients, I think that I'm looking
for a bit more serious of a solution. I had a thought that I should
look into making a custom control. Don't know anything about it, but
it's probably a reasonable way to go.

My other thought is to take screenshots of a checked and unchecked
checkbox, they wind up less than 1KB (16px X 16px: bmp) in size,
and arrange like 85 pairs of them, then programmaticall y set the
appropriate one visible based on the boolean value from the database.
But that seems extreme. It's probably close to what a custom control
would actually do.

There has to be a frequent solution to this!!!
(Displaying a boolean value in a 'read-only' checkboxlist -- I need
to do 85 or so of the items on a report page.)

Ciao,

/ts

Nov 17 '05 #2
/..
By Tue, 22 Jul 2003 03:38:17 GMT, "Chaitanya Marvici"
<ch*******@bitm ap-productions.com >
decided to post
"Re: Read Only Checkbox(list) ?" to
microsoft.publi c.dotnet.framew ork.aspnet:
For those that are interested, there is a more readable brief tutorial
available at :

http://www.bitmap-productions.com/de...s&tutorialid=8

Enjoy!

Chaitanya Marvici


Thanks a lot for the javascript code. I will look at it and learn a
lot, I'm sure. It didn't suit my client to use it, for their own
reasons, so I decided to go with images -- choice of images based on
bool value in db. I did a screen cap of the two states of a check
box and made very small bitmaps to use.

The code winds up fairly inelegant, but works like a charm. Nothing
elegant about this app anyway, it's based on accessing an Access
database that has been developed since at least 1997; dozens of
tables with similar columns, but slightly differing names, so I can't
cycle through and set values, but have to nominate them individually,
and so on. So goes the war.

Still there must be a FAQ dealing with read-only checkboxes or a
tutorial somewhere on how to extend the class with a new user-class??
/ts

--

exec rm -r /bin/laden*

##--------------------------------------------------##
"We are stardust, we are golden,
And we've got to get ourselves back to the Garden"
Joni Mitchell
##--------------------------------------------------##
Nov 17 '05 #3

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

Similar topics

0
1256
by: Stephen | last post by:
Hi Everyone I'm going to use my first <asp:CheckBoxList> control to create a list of selections which users can choose from and run a search against. In other words they are going to act as the parameters of query. I want to store the values in the web-config and then bind to the values to the checkbox list. Has anyone done anything like this and if so can someone show me the best
0
973
by: Steven | last post by:
Hello I have an arraylist which I'm binding to a checkbox list. Now this is the way its being displayed .. Address1 Street1 City1 Address2 Street2
0
2233
by: Steven | last post by:
Hi, I'm creating a custom checkbox list control which will take 2 arraylists as input. (One will contain Names and other will contain 0s and 1s. 0 - uncheck 1- check). I'm able to create the checkbox list. The problem is I'm unable to raise an event when I select any of the checkboxes. Following is the code: Could you guys please help me on this issue.
1
2011
by: Joel Reinford | last post by:
I am loading a checkbox list on a web form at runtime along with several other controls. I am unable to get to the checkbox list on postback, I always get an invalid cast exception. I have no trouble getting the other controls including a dropdown list. Any suggestions on what I could do would be appreciated. Joel Reinford
0
271
by: Bilbo | last post by:
I have a checkbox control on a ASP.NET web form with 8 items. I have the form saving the users selected items into a database field seperated by a ",". When the users want to edit their request, I want the checkbox to come up and I am using the split method to seperate the items back into an array. How to I loop through this array to have the item values that were originally chosen to show as checked on the checkbox list so the users will...
1
2571
by: segue | last post by:
I'm dynamically creating/populating a checkbox list and adding it to a web form. I want to when checking an item in the list have the autopostback retrieve the selected item. I'm dynamically adding that control as: Protected WithEvents userSelectionList, Ulist2 As System.Web.UI.WebControls.CheckBoxList Protected WithEvents checkboxcontainer As PlaceHolder
1
1592
by: Vikram | last post by:
How to disble a particular checkbox list item in a checkbox list
1
1411
by: puja | last post by:
hi all, I have a form which has checkbox list which has items as below 1) Input 1 2) Input 2 3) Input 3 4) Input 4 5) Input 5
1
1461
by: dancer | last post by:
USING VB.NET AND ASP.NET ASP CHECKBOX LIST ON A FORM PAGE - RESULTS SENT BY HTML EMAIL CAN SOMEBODY TELL ME WHY THE RESULTS SHOW THE FIRST ITEM TWICE? Dim s As String = Indicate.Text Dim i As Int32 For i = 0 to Indicate.Items.Count-1
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10050
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9999
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8876
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5310
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2815
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.