jQuery和自动回发冲突 [英] jquery and autopostback conflict

查看:54
本文介绍了jQuery和自动回发冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有3个下拉列表和一个表格形式的网格.
我使用jquery将数据填充到dropdownlist中,而第3个dropdownlist中有一个autopostback事件和selected_indexchanged事件.

当我从第三个下拉列表中选择一个值时,所有下拉列表数据都消失了,但这根本不公平.

我希望该数据不会从任何下拉列表中消失,并且从第三个下拉列表中选择数据之后,它将转到selected_indexchanged事件,并将数据填充到gridview.

Hi,
I have 3 dropdownlist and a grid in a form.
I used jquery to populate data to the dropdownlist and 3rd dropdownlist have a autopostback event and selected_indexchanged event.

When I select a value from 3rd dropdownlist then all dropdownist data vanished but this is not fair at all.

I want that data will not be vanished from any dropdownlist and after selecting data from third dropdownlist it will go to the selected_indexchanged event and will popuate data to gridview.

推荐答案

Some您选择的是:

1.如果尚未执行此操作,请在UpdatePanel中包装第三个下拉列表.
在页面加载事件中使用ScriptManager注册所有与JS相关的代码(.js文件和脚本块).

2.从下拉列表中删除自动回发,并使用页面方法"从Java脚本调用任何服务器端函数.

3.从下拉列表中删除自动回发,并使用jQuery中的任何AJAX方法来调用函数背后的代码.

希望这对您有帮助.
Some of the choice you have are:

1. Wrap third drop down list inside an UpdatePanel if you already have not done this.
Register all your JS related code (.js files & script blocks) using ScriptManager on page load event.

2. Remove auto post back from the drop down and use "page methods" to call any server side function from java script.

3. Remove auto post back from the drop down and use any of the AJAX methods in jQuery to call your code behind function.

Hope this helps.


我使用jquery将数据填充到了dropdownlist中,而第3个dropdownlist中有一个autopostback事件和selected_indexchanged事件.
当我从第三个下拉列表中选择一个值时,所有下拉列表数据都消失了,但这根本不公平.
I used jquery to populate data to the dropdownlist and 3rd dropdownlist have a autopostback event and selected_indexchanged event.
When I select a value from 3rd dropdownlist then all dropdownist data vanished but this is not fair at all.


这是由于ViewState而发生的.当使用JQuery将数据填充到DropDownList 时,ViewState 保持与页面加载期间相同的状态.第一次加载时,autopostback 导致第一个和第二个DropDownLists 变为空白.


This is happening due to ViewState. When you are populating data to the DropDownList using JQuery, the ViewState remains same as it was during page load. And autopostback causes 1st and 2nd DropDownLists to blank as it was loaded first time.

我希望数据不会从任何下拉列表中消失,并且从第三个下拉列表中选择数据之后,它将转到selected_indexchanged事件,并将数据填充到gridview中.
I want that data will not be vanished from any dropdownlist and after selecting data from third dropdownlist it will go to the selected_indexchanged event and will popuate data to gridview.



为什么不使用UpdatePanel 并与Selected_IndexChanged事件异步使用触发器来填充GridView.希望这会对您有所帮助.



Why don''t you use an UpdatePanel and use a trigger asynchronously with Selected_IndexChanged event to populate the GridView. Hope this will help you.


只要做autopostback = false

大声笑
just do autopostback = false

lol


这篇关于jQuery和自动回发冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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