This might be fairly easy to do. Hopefully, it is.
(asp.net 2 / vb)
I have a Drop Down List and in th code-behind vb file, I'd like to
optionally add a OnSelectedIndex Changed attribute to it. Depending on
whether certain conditions are met when the page loads, I'd like to be able
to optionally add this attribute to my DDL. Does this make sense? I tried
using this but it doesn't work:
ddlOperatingIte ms.Attributes.A dd("OnSelectedI ndexChanged",
"ddlExpenseItem s_SelectedIndex Change")
This shows up in the html source code:
OnSelectedIndex Changed="ddlExp enseItems_Selec tedIndexChange"
Essentially what I'm trying to accomplish is that **under certain
conditions**, require the user to provide a brief explaination if they chose
"Other" in the DDL. The txtbox and RequiredValidat or become enabled. The
trick is optionally making this DDL change on SelectedIndex. I don't want
this to **always** be in place.
Here's clips of my code.
Sub Page_load
If myVariable= True Then
ddlOperatingIte ms.Attributes.A dd("OnSelectedI ndexChanged",
"ddlExpenseItem s_SelectedIndex Change")
End If
End Sub
Protected Sub ddlExpenseItems _SelectedIndexC hange(ByVal Sender As Object,
ByVal E As EventArgs)
If ddlOperatingIte ms.SelectedValu e = XXX Then
txtOtherDescrip tion.Enabled = True
txtOtherDescrip tion.Text = ""
OtherDescRequir ed.Enabled = True
Else
txtOtherDescrip tion.Enabled = False
txtOtherDescrip tion.Text = "Not Required"
OtherDescRequir ed.Enabled = False
End If
End Sub
(asp.net 2 / vb)
I have a Drop Down List and in th code-behind vb file, I'd like to
optionally add a OnSelectedIndex Changed attribute to it. Depending on
whether certain conditions are met when the page loads, I'd like to be able
to optionally add this attribute to my DDL. Does this make sense? I tried
using this but it doesn't work:
ddlOperatingIte ms.Attributes.A dd("OnSelectedI ndexChanged",
"ddlExpenseItem s_SelectedIndex Change")
This shows up in the html source code:
OnSelectedIndex Changed="ddlExp enseItems_Selec tedIndexChange"
Essentially what I'm trying to accomplish is that **under certain
conditions**, require the user to provide a brief explaination if they chose
"Other" in the DDL. The txtbox and RequiredValidat or become enabled. The
trick is optionally making this DDL change on SelectedIndex. I don't want
this to **always** be in place.
Here's clips of my code.
Sub Page_load
If myVariable= True Then
ddlOperatingIte ms.Attributes.A dd("OnSelectedI ndexChanged",
"ddlExpenseItem s_SelectedIndex Change")
End If
End Sub
Protected Sub ddlExpenseItems _SelectedIndexC hange(ByVal Sender As Object,
ByVal E As EventArgs)
If ddlOperatingIte ms.SelectedValu e = XXX Then
txtOtherDescrip tion.Enabled = True
txtOtherDescrip tion.Text = ""
OtherDescRequir ed.Enabled = True
Else
txtOtherDescrip tion.Enabled = False
txtOtherDescrip tion.Text = "Not Required"
OtherDescRequir ed.Enabled = False
End If
End Sub
Comment