Solved

Zero bit value = Checked

Posted on 2010-08-26
3
433 Views
Last Modified: 2012-05-10
Hi,

The code below will display a checkbox as checked and show a table containing a text box if the bit value of a field in the db is a 1. If the bit value is 0, it will display just the checkbox as unchecked. I have several of these on the page and they work fine.

However, I now have the reverse things and show a checkbox as checked and a table containing a text box if the bit value is 0. In other words, a bit value of 0 will display the check box as checked and display the table containing the textbox. It is the opposite of the conditions described in the code below.

So, what changes do I need to make so that a 0 bit value will cause the checkbox to be checked and show the table containing the textbox?

Thanks!





Markup:

function RESReturnCurrentIns(chk) {
        ShowControl('tblRESReturnCurrentIns', chk.checked);
    }



                        <table > <tr >                           
                                    <td align="left"><asp:CheckBox ID="ckbRESReturnCurrentFlg"  runat="server"  Checked='<%# Bind("RESReturnCurrentFlg")%>' /></td>                                          
                                    <td width="100%">
                                        <table id="tblRESReturnCurrent" style="display:none">
                                            <tr>
                                               <td align="right"><asp:Label ID="lblRESReturnCurrent" style="vertical-align:middle;" runat="server" Text="Comment:" ></asp:Label>&nbsp;&nbsp;</td>
                                                <td align="left" ><asp:TextBox ID="txtRESReturnCurrentNotes" runat="server" Text='<%# Bind("RESReturnCurrentNotes") %>'></asp:TextBox></td>
                                             </tr>
                                        </table>
                                        </td>
                                </tr>                        
                            </table>



Code behind:


 Dim ckbRESReturnCurrentInsFlg As CheckBox = CType(CType(sender, FormView).FindControl("ckbRESReturnCurrentInsFlg"), CheckBox)
                If ckbRESReturnCurrentInsFlg IsNot Nothing Then
                    ckbRESReturnCurrentInsFlg.Attributes("onclick") = "RESReturnCurrentIns(this);"
                    If hasValue Then ScriptManager.RegisterStartupScript(Me, Me.GetType, "RESRtnIns", String.Format("RESReturnCurrentIns(document.getElementById('{0}'));", ckbRESReturnCurrentInsFlg.ClientID), True)
                End If




0
Comment
Question by:jaysch
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 400 total points
ID: 33538460
Try :

function RESReturnCurrentIns(chk) {
        ShowControl('tblRESReturnCurrentIns', !chk.checked);
    }

(we use an exclamation before chk.checked)
0
 

Author Closing Comment

by:jaysch
ID: 33544367
Works!

Thanks!!
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33544451
You're welcome! Thanks for the points!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question