如何在不加载页面的情况下设置下拉绑定? [英] how to set a dropdown binding without loading a page ?

查看:76
本文介绍了如何在不加载页面的情况下设置下拉绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨每一个,

现在我正在开发一个网站,在这里我需要使用下拉框。在那种情况下,下载是从DB加载的,但我的问题是每当下拉列表被选中或选择值时,页面将自动重新加载。其他文本框和检查值是消失。在这里,我将再次填写文本框,以避免在我的下拉选择中重新加载页面。

i希望你们都明白我的问题。

解决方案

全部你需要使用UpdatePanel。

这是一个例子



< form id =form1runat =server>

< asp:scriptmanager runat =serverid =ScriptManager1xmlns:asp =#unknown>

< asp:updatepanel runat =server id =UpdatePanel1xmlns:asp =#unknown>

< contenttemplate>

< asp:dropdownlist runat =serverid =DropDown1autopostback =true>

< asp:listitem text =DropDown1Item1value = DropDown1Value1>

< asp:listitem text =DropDown1Item2value =DropDown1Value2>

< asp:listitem text =DropDown1Item3value = DropDown1Value3>







< / form>


你显然只是在学习ASP.NET。我推荐学习MVC,它更好。



如果你将AutoPostback设置为false,你的控件将不会导致回发。


< blockquote>设置下拉列表AutoPostBack为false



 AutoPostBack =false



< asp:DropDownList ID =DropDownList1AutoPostBack =falserunat =server> 
< / asp:DropDownList>


hi Every one,
Now i am developing a website, here i need to work with dropdown box. In that situation dropdown is loaded from DB but my problem is whenever dropdown is Binded or value selected, the page will be automatic Reloaded. other textbox and check values are Disappear. here i will again fill the textbox how to avoid page reload in my dropdown selection.
i hope you all understand my problem.

解决方案

All you need to use UpdatePanel.
Here is a example

<form id="form1" runat="server">
<asp:scriptmanager runat="server" id="ScriptManager1" xmlns:asp="#unknown">
<asp:updatepanel runat="server" id="UpdatePanel1" xmlns:asp="#unknown">
<contenttemplate>
<asp:dropdownlist runat="server" id="DropDown1" autopostback="true">
<asp:listitem text="DropDown1Item1" value="DropDown1Value1">
<asp:listitem text="DropDown1Item2" value="DropDown1Value2">
<asp:listitem text="DropDown1Item3" value="DropDown1Value3">



</form>


You are obviously just learning ASP.NET. I recommend learning MVC instead, it's better.

If you set AutoPostback to false, your control won't cause a postback.


Set dropdown AutoPostBack to false

AutoPostBack="false"


<asp:DropDownList ID="DropDownList1" AutoPostBack="false" runat="server">
    </asp:DropDownList>


这篇关于如何在不加载页面的情况下设置下拉绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆