Results 1 to 4 of 4

Thread: Checkbox Disabled

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2009
    Posts
    1,058

    Checkbox Disabled

    Hi,

    My page was created with a multiview which has 3 views.

    Now on one of the view I have a checkbox called chkpeer. So, when this checkbox is checked it triggers a submit button to be set to visible and active with the code below;

    Code:
      Protected Sub chkpeer_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkpeer.CheckedChanged
    
            If chkpeer.Checked = True Then
                chkpeer.Enabled = True
                btnSub.Visible = True
            Else
                btnSub.Visible = False
            End If
    
        End Sub
    The asp code is
    Code:
    <asp:CheckBox ID="chkpeer" runat="server" CssClass="checkbox" AutoPostBack = "True"  />
    Now the problem is, when I check chkpeer - btnsub becomes visible set to TRUE. Then when I move to the next View without clicking the submit button then return to the view with chkpeer,

    1) chkpeer is still ticked but disabled
    2) btnsub visible is SET to FALSE.

    I would prefer one of the following

    Either have the chkpeer checked - enabled and btnSub still Visible (Ideally)
    Or Chkpeer unchecked and enabled so that when I check it again it activates the btnSub ..

    Please help!! Thank you

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Checkbox Disabled

    try asking in the ASP.Net forum:

    http://www.vbforums.com/forumdisplay.php?31-ASP-NET

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Checkbox Disabled

    Thread moved to the 'ASP.Net' forum, which is where questions about .Net web pages belong

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Checkbox Disabled

    Hello dr223,

    The problem here is that you are doing multiple postbacks to the server, which is causing the state of the button to change.

    If the only thing that you are doing when the CheckBox gets selected, is to enable a button, you might want to look into doing this on the client side, and stop controlling the state from the server.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width