Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 30-Mar-16 22:55pm
v2
Comments
Karthik_Mahalingam 31-Mar-16 1:47am    
you will have to modify the MultiDropDownLib:MultiDropDown Library for handling such events.
Since it is not a direct asp control.
Karthik_Mahalingam 31-Mar-16 4:25am    
do u have the source code for that library?
Karthik_Mahalingam 31-Mar-16 5:20am    
then you can write some event handler to it.
without seeing code, i cant give you a proper solution..
Member 12255144 1-Apr-16 1:35am    
k sir thank u so much
Karthik_Mahalingam 1-Apr-16 1:48am    
:)

1 solution

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[^]
 
Share this answer
 
v3
Comments
Member 12255144 1-Apr-16 0:53am    
hello thomas... actually through jquery or javascript i can call only static method so i can't able to access the asp controls.and also i can't access asp controls in non-static method which is called by static method.please give a solution for this
Thomas Nielsen - getCore 1-Apr-16 3:54am    
yea just pust clientidmode=Static on the control, then it has the same name client side, only there it's a container of sorts. very often a div.

But of cause if you abandon the idea of using a control like with the jquery suggestion (See the link), you don't need to access a page method at all.

You cannot call non static methods from a static method without passing an object and using reflection and well, not for web :)

However you can call static page methods to populate data and they just need som parameters to enable serving of most UI ideas, i'll add a link and update solution with example.
Member 12255144 1-Apr-16 4:31am    
thank you so much..but if i add clientidmode=Static multidropdownlist control can't be accessible.it has been created with the help of HTML elements in a library file.


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

please let me know as soon as possible that how to set the autopostback property is true so that i can call server side function to access controls for multidropdownlist.
Thomas Nielsen - getCore 1-Apr-16 5:26am    
I see your article, you cannot use clientidmode=static to get reference when it's a user control, but then you need to assign the clientid to some variable and then add click notification, while ultimately using the .js methods included in the sample article to perform the actual postback when appropropriate. As i wrote it should wait for possible more than one selection and therefore it cannot have autopostback, because that would be not waiting :) but is i'm trying to relay to you, it's possible to refresh whatever it controls in another way, but you have to accept it's another way than you originally thougth :) alternatively you must reengineer the usercontrol.
I'll update with links to facilitate teqniques outlined
Member 12255144 1-Apr-16 5:45am    
yeah fine sir thank you so much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900