Runtime SelectedIndexChanged!

  • Thread starter Thread starter Adam Knight
  • Start date Start date
A

Adam Knight

Hi all,

I have a DropDownList that i want to attach a OnSelectedIndexChange event
Dynamically.
So far my attempts have failed.

'determine if report being generated is a 'Question Statistics' report
If(ddlReportTypes.SelectedValue = "q") Then

'specify OnSelectedIndexChanged method Sub
'tried
ddlAssessmentAreas.SelectedIndexChanged = "LoadQuestions"
'and
ddlAssessmentAreas.OnSelectedIndexChanged = "LoadQuestions"

End If

Both options i have tried have generated errors?

Can anyone steer me in the right direction?

Adam
 
Adam,

Do you mean you want something to happen clientside onSelectedIndexChanged?

If so then you need to attach a javascript to the control using it's
attributes method.

DropDownList.Attributes.Add("onSelectedIndexChanged", "your javascript
here")

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
No not after javascript...

I am wanting to attach the OnSelectedIndexChanged (ASP.NET event for
DropDownList) Method dynamically to a DropDownList.

Both these options have failed.

ddlAssessmentAreas.SelectedIndexChanged = "LoadQuestions" \\call
LoadQuestions function onSelectedIndexChange //server side
'and
ddlAssessmentAreas.OnSelectedIndexChanged = "LoadQuestions" \\call
LoadQuestions function onSelectedIndexChange //server side

Cheers,
Adam
 
Adam,

The most common cause of this failing is that if the control is being added
to the page dynamically it has to be added again on post back. If the
control isn't recreated on post back then .NET never connects up the post
back event to the control and the event doesn't fire.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top