DropDownList Problem

R

Roshawn

Hi,

I have a DDL server control on my web form. I'm having difficulty trying to
fire the OnSelectedIndexChanged event. I've specified a procedure to handle
the event. Whenever I changed the selected index of the DDL server control,
the event doesn't fire at all. Below are the settings for the DDL server
control:

<asp:dropdownlist autopostback="true" id="Dlist" runat="server"
onselectedindexchanged="Selection_Changed" />

Here is the code for the procedure to handle the event:

Sub Selection_Changed(Byval s as Object, Byval e as EventArgs) Handles
Dlist.SelectedIndexChanged
Me.ViewState("page") = Me.Dlist.SelectedItem.Value
Call GetData()
End Sub

What I want to do is fire the event everytime there is a change in the DDL.
In other words, I'd like the page to be posted back to the server
immediately when there is a selection change in the DDL. As it stands,
nothing happens when I select a new value in the DDL.

Can anyone help me with this problem?

Thanks,
Roshawn

Sorry for cross-posting
 
G

Greg Burns

<asp:DropDownList id="Dlist" runat="server" AutoPostBack="True" />

Private Sub Selection_Changed(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Dlist.SelectedIndexChanged
'Dlist.SelectedIndexChanged()
Me.ViewState("page") = Me.Dlist.SelectedItem.Value
'Call GetData()
End Sub

This works for me. I would get rid of the
onselectedindexchanged="Selection_Changed" since you already have Handles
clause on your event procedure. Notice the Private keyword also, this
doesn't need to be public when done this way.

(Note: watch out when autoposting with a dropdownlist. The scroll wheel
becomes a real PITA.)

Greg
 
R

Roshawn

Hi Greg,

Thanks for your response. Unfortunately, the problem remains. But
something else could be hindering my success, namely the script that is
generated by the control. Whenever I run the app and select View Source to
view the HTML thats rendered, I notice something in the script. Here's the
code in the script that appears to be the problem:

if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {

If I select View Source on other ASP.NET sites and peek at the _dopostback()
function, it always contains the name "microsoft" instead of "netscape".
Could this be the culprit? And if so, how do I change it in the .NET IDE
(if possible)?

Thanks,
Roshawn
 
G

Greg Burns

Mine also has "netscape" in the __doPostBack function.

This is completely normally. It is just ASPNET adjusting itself for the
iconsistentsies in the different browser types. Although, I don't know why
you are seeing sites that have "microsoft" listed here. I just checked out
some popular sites using ASPNET, and they all have the word netscape. Maybe
those pages you looked at are doing something different and need to check
something else.

Can you post your .aspx page for me to look at?

Greg
 
R

Roshawn

Hi Greg,

I tried running my app in another browser (Mozilla) and it works fine.
Could it be that I don't have scripting enabled in IE? How do you turn it
on?

Thanks,
Roshawn
 
R

Roshawn

I don't think that I turn off scripting in my browser. I suppose something
that I downloaded did. The program was some type of html validator that
created a new toolbar in IE. It caused a few minor problems. When I
uninstalled it, my IE browser has been working somewhat strange.

Thanks for the info, Greg. You've been a big help. Everything works now!!
:)

Roshawn
 

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

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,085
Latest member
cryptooseoagencies

Latest Threads

Top