首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

小弟我为了往服务器传值用autopostback,小弟我已经把dropdownlist放到updatapanel里面了 但是页面还是刷新 为什么 代码如下

2012-06-01 
我为了往服务器传值用autopostback,我已经把dropdownlist放到updatapanel里面了 但是页面还是刷新 为什么

我为了往服务器传值用autopostback,我已经把dropdownlist放到updatapanel里面了 但是页面还是刷新 为什么 代码如下
前台大概这样的

HTML code
 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="zc.aspx.cs" Inherits="DtCms.Web.Aspx.zc" EnableEventValidation="false" %><%@ Register TagPrefix="DtContorl" Namespace="DtCms.Web.UI" Assembly="DtCms.Web.UI" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title><%= SiteConfig.WebName %></title><!-- ===== css ===== --></head><body  onLoad="init()">    <form id="form1" runat="server">    <asp:ScriptManager ID="ScriptManager1" runat="server">    </asp:ScriptManager><div><td width="200px"></td><td width="130px" align="right">籍贯:</td><td width="130px">            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">            <ContentTemplate>            <asp:DropDownList ID="ddlProvince" runat="server"                     onselectedindexchanged="ddlProvince_SelectedIndexChanged1" AutoPostBack="true">            </asp:DropDownList>            <asp:DropDownList ID="ddlCity" runat="server">            </asp:DropDownList>            </ContentTemplate>            </asp:UpdatePanel>        </td></div>    </form></body></html>

后台大概这样的
C# code
 protected void ddlProvince_SelectedIndexChanged1(object sender, EventArgs e)        {            ddlCity.DataSource = bll.GetCity(ddlProvince.SelectedValue.ToString()).DefaultView;//根据页面的返回值传递信息绑定城市信息            ddlCity.DataTextField = bll.GetCity(ddlProvince.SelectedValue.ToString()).Columns[0].ToString();            ddlCity.DataBind();        } 


[解决办法]
UpdatePanel要放在一个完整的标签中才会不刷新,你用UpdatePanel把table包住
[解决办法]
没用的dropdownlist 压根就不支持updatepannel方式的无刷新
[解决办法]
C# code
<form id="form1" runat="server">    <asp:ScriptManager ID="ScriptManager1" runat="server">    </asp:ScriptManager>    <div>        <table>            <tr>                <td width="130px" align="right">                    籍贯:                </td>                <td width="130px">                    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">                        <ContentTemplate>                            <asp:DropDownList ID="ddlProvince" runat="server" OnSelectedIndexChanged="ddlProvince_SelectedIndexChanged1"                                AutoPostBack="true">                                <asp:ListItem Text="1" Value="1"></asp:ListItem>                                <asp:ListItem Text="2" Value="2"></asp:ListItem>                            </asp:DropDownList>                            <asp:DropDownList ID="ddlCity" runat="server">                            </asp:DropDownList>                        </ContentTemplate>                    </asp:UpdatePanel>                </td>            </tr>        </table>    </div>    </form> 


[解决办法]

探讨
引用:

C# code

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<table>
<tr>
<td width="13……

和我做的有什么不同 我哪里弄错了能给说下嘛……

[解决办法]
C# code
 <asp:ScriptManager runat="server">        </asp:ScriptManager>        <asp:UpdatePanel runat="server">            <ContentTemplate>                <asp:DropDownList ID="ddlTest" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlTest_SelectedIndexChanged">                    <asp:ListItem Text="aaaa" Value="1"></asp:ListItem>                    <asp:ListItem Text="bbb" Value="2"></asp:ListItem>                    <asp:ListItem Text="ccc" Value="3"></asp:ListItem>                    <asp:ListItem Text="ddd" Value="4"></asp:ListItem>                </asp:DropDownList>            </ContentTemplate>            <Triggers>                                <asp:AsyncPostBackTrigger ControlID="ddlTest"                     EventName="SelectedIndexChanged" />                                </Triggers>        </asp:UpdatePanel>
[解决办法]
updatepanel 要指定控件及控件的事件
<triggers>标签 好像是这个功能
[解决办法]
也许楼上的正确

热点排行