如何为ASP.NET中的多选下拉控件启用autopostback? [英] How can I enable the autopostback is true for a multiple selection dropdown control in ASP.NET?

查看:76
本文介绍了如何为ASP.NET中的多选下拉控件启用autopostback?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自动回发在asp.net中的多重选择下拉控件中不起作用。虽然我在该控件中指定了autopostback =true但它不起作用所以如何启用autopostback是真的以便我可以呼叫服务器端功能

http://www.codeproject.com/Articles/219977/MultiDropDown-A-multiple-selection-Dropdown-contro



< MultiDropDownLib:MultiDropDown ID =MultiDropDown2runat =serverDropdownOnMouseOver =true

DropdownOnFocus =trueTextBoxClass =textbox1ImageButtonClass =imagebutton1

TooltipClass =tooltip1DropdownClass =dropdown1autopostback =true>



我尝试过:



虽然我指定autopostback =true在该控件中它将无法工作所以如何启用autopostback为true以便我可以调用服务器端函数

auto post back doesn't work in A Multiple Selection Dropdown Control in asp.net.though i specified autopostback="true" in that control it won't work so how can i enable the autopostback is true so that i can call server side function
http://www.codeproject.com/Articles/219977/MultiDropDown-A-multiple-selection-Dropdown-contro

<MultiDropDownLib:MultiDropDown ID="MultiDropDown2" runat="server" DropdownOnMouseOver="true"
DropdownOnFocus="true" TextBoxClass="textbox1" ImageButtonClass="imagebutton1"
TooltipClass="tooltip1" DropdownClass="dropdown1" autopostback="true">

What I have tried:

though i specified autopostback="true" in that control it won't work so how can i enable the autopostback is true so that i can call server side function

推荐答案

逻辑上你不能在等待回发时自动回复直到n由于您不知道选择何时完成,但是有多种方式已经完成选择。



如果您放弃了服务器端控制的想法,你可以在这个问题领域用JQuery和AJAX做魔术。服务器端控件是Web上的问题子,因为它们仅在服务器上执行请求时存在,但是它们仍然需要它们的状态用于下一个请求...

大多数现代Web方法放弃服务器端例如,控制Web表单和mvc之间的主要区别之一就是不再有'Page'作为控件容器。



因此,考虑制作一个不同的实现,根本不使用服务器端控件,如下所示: Bootstrap Multiselect | jQuery插件 [ ^ ]



然后你只需处理你的回发中的值(来自jquery)或甚至更好的你的ajax调用(来自jquery)



下面是一个使用下面的页面方法的例子,如果你的初始加载有必要的值来控制它在客户端上(确保),那么jquery可以与客户端进行交互并进行异步更新,这一切都给了一个非常好的看法当用户点击时,感觉到你的网站停止'跳'。

使用jQuery直接调用ASP.NET AJAX页面方法 [ ^ ]



所以传递容器名称实例的名称对客户端的用户控制可以是don例如,像这样:

[< a href =http://stackoverflow.com/questions/16147288/not-getting-clientid-in-asp-nettarget =_ blanktitle =新窗口> ^ ]



并使用jquery将事件处理程序添加到dom元素: .click()| jQuery API文档 [ ^ ]
Logically you cannot autopostback while waiting to postback until the number of selections have completed because you don't know when the selection has finished, but there are ways.

If you abandon the idea of a server side control at all, you can do magic with JQuery and AJAX in this problem field. Server side controls are problem childs on the web, because they only exist while request is being executed on server, but they still need their state for the next request...
Most modern web approaches abandon server side controls for instance one of the major differences between web forms and mvc is that there is nolonger a 'Page' as a control container.

Therefore consider making a different implementation, not using server side control at all, like this one: Bootstrap Multiselect | jQuery Plugins[^]

Then you'll just handle the values in your postback (from jquery) or even better your ajax call (from jquery)

Here's an example of using page methods below, if your inital load has place necessary values to control this on the client (make sure), then jquery can interact with client and make asyncronous updates wich all in all gives a very nice look'n'feel to your site as it stops 'jumping' when users click.
Using jQuery to directly call ASP.NET AJAX page methods[^]

So passing the name of the instance of the container name of a user control to the client side can be done for instance like this:
[^]

and adding eventhandlers to a dom element using jquery like this: .click() | jQuery API Documentation[^]


这篇关于如何为ASP.NET中的多选下拉控件启用autopostback?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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