本文介绍了如何在页面刷新后取消选中复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 在我的表单中,我有一个复选框(加载时未选中状态)。单击此复选框我必须在dropdown中加载所有详细信息。如果未选中它将在下拉列表中加载最少的详细信息。 问题: 首先,我检查了复选框然后取消选中它。然后我只刷新页面。 那个时候复选框会自动检查。和其他控件如此页面中的radiobuttions被禁用。请帮我解决这个问题。??? 代码 ---------- < asp:UpdatePanel ID = updChkAllPort runat = server UpdateMode = 始终 > < contenttemplate > < div class = table_column_50 style = margin-left:-3px!重要的 runat = server id = divSelecAllPort > < asp:CheckBox runat = server ID = chListAllPort 已检查 = false 文本 = 列出所有端口 OnCheckedChanged = chListAllPort_changed AutoPostBack = true CssClass = 复选框样式 SkinID = label-style-data / > < / contenttemplate > ---------------------- //复选框chaged ------------------------ protected void chListAllPort_changed( object sender,EventArgs e) { List< crewport> nextPort = new List< crewport>(); nextPort = CrewReliefPlannerManager.CrewLastPortList(Convert.ToInt32(hidVesselId.Value),chListAllPort.Checked? true : false ); ddlPort.DataSource = nextPort; ddlPort.ValueField = PortId; ddlPort.TextField = PortName; ddlPort.DataBind(); ddlPort.NullText = Resources.ErrorMessage.ResourceManager.GetString( Drop_Down_Select)。ToString (); } 解决方案 然后你应该设置AutoPostBack = false,这将阻止页面在检查时回发/取消。 In my form I have one checkbox (Unchecked state on load).by clicking this checkbox I have to load all the details in dropdown.if unchecked It will load minimum details in dropdown.Problem: At first, I have checked the checkbox then unchecked it.Then I just refreshing the page.That time the checkbox become automatically checked. and other controls like radiobuttions in this page become disabled.Please help me to solve this problem.???Code---------- <asp:UpdatePanel ID="updChkAllPort" runat="server" UpdateMode="Always"> <contenttemplate> <div class="table_column_50" style="margin-left: -3px ! important" runat="server" id="divSelecAllPort"> <asp:CheckBox runat="server" ID="chListAllPort" Checked ="false" Text="List all ports" OnCheckedChanged="chListAllPort_changed" AutoPostBack="true" CssClass="checkbox-style" SkinID="label-style-data" /> </contenttemplate> ----------------------// checkbox chaged ------------------------ protected void chListAllPort_changed(object sender, EventArgs e) { List<crewport> nextPort = new List<crewport>(); nextPort = CrewReliefPlannerManager.CrewLastPortList(Convert.ToInt32(hidVesselId.Value), chListAllPort.Checked ? true : false); ddlPort.DataSource = nextPort; ddlPort.ValueField = "PortId"; ddlPort.TextField = "PortName"; ddlPort.DataBind(); ddlPort.NullText = Resources.ErrorMessage.ResourceManager.GetString("Drop_Down_Select").ToString(); } 解决方案 Then you should set AutoPostBack=false, this will prevent page from posting back on check/uncheck. 这篇关于如何在页面刷新后取消选中复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-21 12:38