我在UpdatePanel中用到了一个三级表单的效果,是用Jquery做的,但当我做这个ajax操作时就会失效
后来添加点JS代码就可解决
<asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional"> <ContentTemplate> <asp:RadioButtonList ID="_rbAddress" runat="server" AutoPostBack="true" onselectedindexchanged="_rbAddress_SelectedIndexChanged1"> </asp:RadioButtonList> <br /> <asp:Panel ID="_panelAddress" runat="server"> <table> <tr><td>收货人姓名:</td><td> <asp:TextBox ID="_txtConsignee" runat="server" MaxLength="25" onblur="checkRealName(this);"></asp:TextBox></td><td> <asp:Label ID="lbl_RealName" runat="server" ForeColor="Red" EnableViewState="false"></asp:Label></td></tr> <tr><td>邮政编码:</td><td> <asp:TextBox ID="_txtPostcode" runat="server" onblur="checkInfo(this,'lbl_PostCode');" MaxLength="6"></asp:TextBox></td><td><asp:Label ID="lbl_PostCode" runat="server" ForeColor="Red" EnableViewState="false"></asp:Label></td></tr> <tr><td>固定电话:</td><td> <asp:TextBox ID="_txtTelNo" runat="server" onblur="checkInfo(this,'lbl_Phone');"></asp:TextBox></td><td><asp:Label ID="lbl_Phone" runat="server" ForeColor="Red" EnableViewState="false"></asp:Label></td></tr> <tr><td>手机号码:</td><td> <asp:TextBox ID="_txtMobile" runat="server" onblur="checkInfo(this,'lbl_Mobile');" MaxLength="11"></asp:TextBox></td><td><asp:Label ID="lbl_Mobile" runat="server" ForeColor="Red" EnableViewState="false"></asp:Label></td></tr> <tr><td>地区:</td><td><div id="ChinaArea"> <select id="province" name="province" style="width: 100px;"></select> <select id="city" name="city" style="width: 100px;"></select> <select id="county" name="county" style="width: 120px;"> </select> <asp:Label ID="_lblPronice" runat="server" Text="上海市" style="display:none"></asp:Label> <asp:Label ID="_lblCity" runat="server" Text="上海市" style="display:none"></asp:Label> <asp:Label ID="_lblDiscount" runat="server" Text="黄浦区" style="display:none"></asp:Label> <asp:HiddenField ID="Tprovince" runat="server" /> <asp:HiddenField ID="TCity" runat="server" /> <asp:HiddenField ID="TCounty" runat="server" /> </div></td></tr> <tr><td>街道小区:</td><td> <asp:TextBox ID="_txtStreet" runat="server" onblur="checkInfo(this,'_lblStreet');" MaxLength="100" Width="100%"></asp:TextBox></td><td><asp:Label ID="_lblStreet" runat="server" ForeColor="Red" EnableViewState="false"></asp:Label></td></tr> <tr><td></td><td> <asp:Button ID="_btnAddressModify" runat="server" Text="修改地址" Visible="false" onclick="_btnAddressModify_Click"/> <asp:Button ID="_btnAddress" runat="server" Text="添加地址" onclick="_btnAddress_Click" Visible="false"/> </td></tr> </table> </asp:Panel> <asp:UpdateProgress ID="UpdateProgress2" runat="server"> <ProgressTemplate><font style="color:Red">正在处理中...</font></ProgressTemplate> </asp:UpdateProgress> </ContentTemplate> </asp:UpdatePanel> <script type="text/javascript"> function reload() { Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); } function EndRequestHandler() { $("#ChinaArea").jChinaArea({ aspnet:true, s1:$("#_lblPronice").attr("innerHTML"),//默认选中的省名 s2:$("#_lblCity").attr("innerHTML"),//默认选中的市名 s3:$("#_lblDiscount").attr("innerHTML")//默认选中的县区名 }); } </script>
? 然后在<body onload="reload();">加入这句话就OK啦
非常感谢网友http://zg672313.blog.163.com/blog/static/81010077201012322426780/