Visualizzazione dei risultati da 1 a 3 su 3

Discussione: problema con if

  1. #1
    Utente di HTML.it
    Registrato dal
    Aug 2009
    Messaggi
    213

    [risolto]problema con if

    Non riesco a capire perchè questa routine non funziona:

    Sub vis(ByVal obj As Object, ByVal e As EventArgs)
    If (maschio.Checked = True) Then
    dpmale.Enabled = True
    dpfemale.Enabled = False
    Else
    dpmale.Enabled = False
    dpfemale.Enabled = True
    End If
    End Sub

    Il codice è questo:
    codice:
    <%@ Page Language="VB" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        Sub vis(ByVal obj As Object, ByVal e As EventArgs)
            If (maschio.Checked = True) Then
                dpmale.Enabled = True
                dpfemale.Enabled = False
            Else
                dpmale.Enabled = False
                dpfemale.Enabled = True
            End If
        End Sub
    
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        Scegli il nome:
    
        Maschio<asp:RadioButton ID="maschio"  runat="server" GroupName="sex" onchecked="vis" checked=true AutoPostBack=true>
        
        </asp:RadioButton>
    
        Femmina<asp:RadioButton ID="femmina"  runat="server" GroupName="sex" onChecked="vis" autopostback=true>
        
        </asp:RadioButton>
    
        <asp:DropDownList ID="dpmale" name="dmaschile" runat="server" enabled=false>
        <asp:ListItem Value="Gino">Gino</asp:ListItem>
        <asp:ListItem Value="Bruno">Bruno</asp:ListItem>
        <asp:ListItem Value="Tony">Tony</asp:ListItem>
        </asp:DropDownList>
        
        <asp:DropDownList ID="dpfemale" name="dfemminile" runat="server" Enabled=false>
        <asp:ListItem Value="Tina">Tina</asp:ListItem>
        <asp:ListItem Value="Silvia">Silvia</asp:ListItem>
        <asp:ListItem Value="Denise">Denise</asp:ListItem>
        </asp:DropDownList>
        
        </div>
        </form>
    </body>
    </html>
    Potreste aiutarmi? Grazie

  2. #2
    Utente di HTML.it
    Registrato dal
    Aug 2009
    Messaggi
    213
    Ho risolto.Non avevo settato l'evento giusto nel radiobutton

  3. #3
    E se qualcuno seleziona per sbaglio il sesso errato??

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.