问题:当郊区下拉列表值更改时 - 页面正在回发。
期望的结果:更改下拉列表中的值更新邮政编码文本框值而不回页(邮政编码文本框通常是隐藏的)
网页代码:
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:DropDownList ID="Suburb" runat="server" DataTextField="LocalityPhrase"
DataValueField="Locality" AutoPostBack="true" class="DropDown" OnSelectedIndexChanged="Suburb_SelectedIndexChanged"/>
<asp:UpdatePanel runat="server" id="UpdatePanelPostCode" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="Postcode" runat="server" Visible="true"/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Suburb" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
代码背后:
Protected Sub Suburb_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Suburb.SelectedIndexChanged
'get postcode from suburb drop down
Dim pCode As String = ""
If Suburb.SelectedValue <> "" Then
pCode = Suburb.SelectedItem.Text.Substring(Len(Suburb.SelectedItem.Text) - 5, 4)
End If
Postcode.Text = pCode
End Sub
答案 0 :(得分:0)
我的安装AJAX工具包似乎有问题。在Visual Studio(2008)中删除并重新加载它,一切都很好。