Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropdown list control, autopost back.. 1

Status
Not open for further replies.

newmem

Programmer
Jul 23, 2002
35
US
Hi All

I have a similar problem as described in thread855-692299
. It didn't solve my error so I'm describing the error I'm getting.

I have a dropdown list which is db-bound and has the autopostback set to true. When
the application runs, the ddl gets all the data etc. But on selecting an item from the list, IE throws a JS error in the status bar - Error:
Object doesn't suport this property or method.

here's a sample code:

<asp:dropdownlist id=&quot;lstType&quot; runat=&quot;server&quot; autopostback=True
OnSelectedIndexChanged=lstType_SelectedIndexChanged&quot;></asp:dropdownlist>

On page-behind ,
Sub lstType_SelectedIndexChanged(ByVal Sender as Object, byVal e As
System.Eventargs) Handles lstType.SelectedIndexChanged

......
End Sub

I have googled for any possible workwound/fix but no luck! I'm totally stuck with it. Can someone point me what's going wrong?

Thanks!

newmem
 
new: looks like for starters you're missing to &quot;'s. One at:

OnSelectedIndexChanged=lstType_SelectedIndexChanged&quot;

which should be:

OnSelectedIndexChanged=&quot;lstType_SelectedIndexChanged&quot;

and the other:

autopostback=True which I would put: ...back=&quot;true&quot;

other than that, seems ok. Here is a modified test page of the one you referenced above - it works fine, but is built in Notepad.

<%@ Page Language=&quot;vb&quot; Debug=&quot;true&quot; %>
<%@ Import Namespace = &quot;Microsoft.VisualBasic&quot; %>
<%@Import Namespace = &quot;System&quot;%>
<script runat=&quot;server&quot;>
Public Sub GetATMList(sender As Object, e As System.EventArgs)
If ddCity.selectedItem.Value = 1 Then
lblTest.Text = &quot;City is ok.&quot;
ElseIf ddCity.selectedItem.Value = 2 Then
lblTest.Text = &quot;City is bankrupt.&quot;
Else
lblTest.Text = &quot;City is far away.&quot;
End IF
End Sub
</script>
<HTML>
<HEAD>
<title>Test</title>
</HEAD>
<body>
<form runat=&quot;server&quot;>
<asp:dropdownlist id=&quot;lstType&quot; runat=&quot;server&quot; autopostback=True OnSelectedIndexChanged=lstType_SelectedIndexChanged&quot;></asp:dropdownlist>

<asp:DropDownList ID=&quot;ddCity&quot; OnSelectedIndexChanged=&quot;GetATMList&quot; AutoPostBack=&quot;true&quot; runat=&quot;server&quot;>
<asp:ListItem Value=&quot;01&quot;>A</asp:ListItem>
<asp:ListItem Value=&quot;02&quot;>B</asp:ListItem>
<asp:ListItem Value=&quot;03&quot;>C</asp:ListItem>
</asp:DropDownList>
<asp:Label id=&quot;lblTest&quot; runat=&quot;server&quot;/>
</form>
</body>
</HTML>
 
Thanks for the reply, Isadore.
The two points you mentioned were typo in the sample code. I matched your code line by line .. and I didn't find anything different. But still nothing happens when I click the dropdownlist and get the javascript error.

newmem
 
new: my mistake; as you can see in my code; I left your dropdown box in place (I was comparing it to mine) and if you used my code line by line it would throw an error.

You would first have to remove your dropdownlist - there should only be &quot;ddCity&quot; there. Perhaps you already noticed that.

As far as the java error; that is strange indeed; not sure what that could be.
 
Hi newmem

When you use a dropdownlist (which renders as a select box) to do an autopostback the .NET has to output a clientside (javascript) function which handles the postback as no client events for the select box can automatically trigger a form submit. this is the case for any web controls other than buttons. Buttons automaticalloy post the form data as they are of type 'submit'.

The function which .NET outputs (which can usually be found i the source code for the page just after the form tag) is called __doPostback(). It takes a coupel of arguments, namely the object which called it (usually passsed with thwe 'this' keyword) and the action whcih triggered the event.

My guess is that your problem is related to this function. I suspect if you check your source code you won't find it there. Why, is another matter but at least it gives you a direction to start looking in. here's a thread from the asp.net forums on this subject - you may be having the same problems...


Rob

Go placidly amidst the noise and haste, and remember what peace there may be in silence - Erhmann 1927
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top