G
Groove
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 OnSelectedIndexChanged 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:
ddlOperatingItems.Attributes.Add("OnSelectedIndexChanged",
"ddlExpenseItems_SelectedIndexChange")
This shows up in the html source code:
OnSelectedIndexChanged="ddlExpenseItems_SelectedIndexChange"
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 RequiredValidator 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
ddlOperatingItems.Attributes.Add("OnSelectedIndexChanged",
"ddlExpenseItems_SelectedIndexChange")
End If
End Sub
Protected Sub ddlExpenseItems_SelectedIndexChange(ByVal Sender As Object,
ByVal E As EventArgs)
If ddlOperatingItems.SelectedValue = XXX Then
txtOtherDescription.Enabled = True
txtOtherDescription.Text = ""
OtherDescRequired.Enabled = True
Else
txtOtherDescription.Enabled = False
txtOtherDescription.Text = "Not Required"
OtherDescRequired.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 OnSelectedIndexChanged 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:
ddlOperatingItems.Attributes.Add("OnSelectedIndexChanged",
"ddlExpenseItems_SelectedIndexChange")
This shows up in the html source code:
OnSelectedIndexChanged="ddlExpenseItems_SelectedIndexChange"
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 RequiredValidator 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
ddlOperatingItems.Attributes.Add("OnSelectedIndexChanged",
"ddlExpenseItems_SelectedIndexChange")
End If
End Sub
Protected Sub ddlExpenseItems_SelectedIndexChange(ByVal Sender As Object,
ByVal E As EventArgs)
If ddlOperatingItems.SelectedValue = XXX Then
txtOtherDescription.Enabled = True
txtOtherDescription.Text = ""
OtherDescRequired.Enabled = True
Else
txtOtherDescription.Enabled = False
txtOtherDescription.Text = "Not Required"
OtherDescRequired.Enabled = False
End If
End Sub