DropDownList设置客户端事件
来源:互联网 发布:老鹰对马刺数据 编辑:程序博客网 时间:2024/05/03 01:48
假设:数据源控件GrdiView,无刷新UpdatePannel,友情提示UpdateProgress,分页下拉框DropDownList
一般情况下:Gridview的分页有linkbutton或者button,这样要是想让UpdateProgress提示,很简单,先让GridView隐藏,然后给它加个OnClientClick就搞定!
在DropDownList的onchange事件里:
function selectChange() { if ($("select option").is(":selected")) { $("#btn11").click(); } }
跳转到:
<asp:DropDownList ID="ddlNeedPage" runat="server" AutoPostBack="true"
onchange="return selectChange();">
</asp:DropDownList>
function clearData() { //$("#<%=_gvGuest.ClientID %>").empty(); $("#_gvGuest").empty(); //$("#<%=lblMessage.ClientID %>").hide(); $("#lblMessage").hide(); }
<asp:LinkButton ID="lnkFirstPage" runat="server" OnClientClick="return clearData();" CommandName="Page" CommandArgument="First" Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex != 0 %>">第一页</asp:LinkButton>
但是DropDownList没有OnClientClick事件,怎么办?
因为上面说了Button有Onclientclick我们可以想到借助Button来转换一下!!!!
解决办法:在页面上放一个隐藏的button:<asp:Button ID="btn11" runat="server" CssClass="btnPage"Style="display: none;" OnClick="btn11_Click"
OnClientClick="return clearData2();"/>
然后再OnClientClick事件里把下拉框的值赋给一个隐藏域
function clearData2() { var hidDDL = $("#_gvGuest_ddlNeedPage").val(); $("#hidNeedPage").attr("value", hidDDL); $("#_gvGuest").empty(); $("#lblMessage").hide(); }
protected void btn11_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(hidNeedPage.Value)) { _gvGuest.PageIndex = Convert.ToInt32(hidNeedPage.Value); BindData(); } }
基本思路就实现了!!!谢谢围观!
2012年12月4日 10:25
- DropDownList设置客户端事件
- javascript dropdownlist 客户端设置
- DropDownList客户端加onchange事件
- 给dropdownlist等控件增加客户端onchange事件
- 给服务器端DropDownList控件添加客户端onchange事件
- 给服务器端DropDownList控件添加客户端onchange事件
- DropDownList 事件
- CustomValidator客户端验证DropDownList
- DropDownList添加onchange()事件
- dropdownlist 设置默认项?
- DropDownList设置值
- 设置dropdownlist选中值
- DropdownList设置空白选项
- DropDownList设置选定项
- dropdownlist ,如何设置默认值
- 为什么设置了DropDownList的AutoPostBack="True"还是不能触发SelectedIndexChanged事件?
- 当dropdownlist变化时候一定要设置autopostback=true 才能激活出发事件
- dropdownlist设置 AutoPostBack=True 时不能触发事件的问题
- org.hibernate.AnnotationException: No identifier specified for entity
- 常见面试题:重写strcpy() 函数原型
- latex 让表格中的单元格换
- Win8 越狱
- TenMinutesToTellurium
- DropDownList设置客户端事件
- Windows下安装openGL的glut库(openGL入门)
- 用GDB反汇编调试linux内核
- 怎样写出高性能的HTML代码
- Xcode 错误- Could not launch app - No such file or directory Error.
- 并行计算——寻找并发性 (功能分解)
- SD卡操作及调试关键点
- asp.net三层架构详解
- Define and declare method in Dojo