visible or not visible

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using the following code to make a textbox visible if a certain item is
selected from the dropdownlist box. On debug it appears to not even fire the
selected index change module. What is wrong

Private Sub ddlMedicalNecessity_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ddlMedicalNecessity.SelectedIndexChanged
If ddlMedicalNecessity.SelectedValue = "Other (please specify):" Then
txtSpecify.Visible = True
Else
txtSpecify.Visible = False
End If
End Sub

I want the textbox to appear only if other (please specify): is selected. I
have tried taking the value of ddlmedicalnecessity.selectedvalue and put in a
variable and then put the variable in if phrase but that does not work
either. Thank you.
 
Chances are the event is not configured in the HTML. There are two ways to
possibly fix this:

1) Ensure the "AutoPostBack" property is set to TRUE. If it is, and still
doesn't work, see #2.

2) Change the access for the method from Private to Publc. Click on the HTML
tab, and find where the dropdownlist is declared. It should look like:
<asp:DropDownList id="DropDownList1" runat="server"></asp:DropDownList>. You
will need to add the "OnSelectIndexChanged" event handler. Make it look like:
<asp:DropDownList id="DropDownList1"
OnSelectIndexChanged="ddlMedicalNecessity_SelectedIndexChanged"
runat="server"></asp:DropDownList>

Recompile and run, and it should work for you.
 
#1 did the trick thank you

UsualDosage said:
Chances are the event is not configured in the HTML. There are two ways to
possibly fix this:

1) Ensure the "AutoPostBack" property is set to TRUE. If it is, and still
doesn't work, see #2.

2) Change the access for the method from Private to Publc. Click on the HTML
tab, and find where the dropdownlist is declared. It should look like:
<asp:DropDownList id="DropDownList1" runat="server"></asp:DropDownList>. You
will need to add the "OnSelectIndexChanged" event handler. Make it look like:
<asp:DropDownList id="DropDownList1"
OnSelectIndexChanged="ddlMedicalNecessity_SelectedIndexChanged"
runat="server"></asp:DropDownList>

Recompile and run, and it should work for you.
 
Back
Top