asp.net - AJAX combobox adding new items without autopostback="true" -
buenos nachos, brief, question is: possible allow users add new items combobox @ runtime without having autopostback property set true? understand needs postback if new item added, not want box postback if user selects different value!
the tag have below. without having autopostback="true"
, comboxbox doesn't allow user add new items box >_<' thoughts?
<ajx:combobox id="cbcompany" runat="server" width="226px" dropdownstyle="dropdown" oniteminserted="addcompany" autocompletemode="suggestappend"> </ajx:combobox>
i know add few more controls , easy workaround, wondering if possible way.
you don't need round-trip server each single change in designed components, client should able handle situations except when server must validate data immediately.
that anti-pattern of needs postback or using .net's lazy version of ajax (when server deals tiny bits like, example, adding items combo) not @ , javascript there simple tasks.
i downloaded source code ajaxcontroltoolkit's combobox , unfortunatelly not provide javascript interface.
you try disabling postback , using like:
<script type="text/javascript"> function additemtodumbcombobox(cb, text) { /* based upon combobox.pre method initializeoptionlist() */ // create new list item var child = document.createelement('li'); child.innerhtml = text; cb.get_optionlistcontrol().appendchild(liitem); // add item internal collection var item = { text: text.trim(); }; array.add(cb._optionlistitems, item); // style listitem default skin cb.initializeoptionlistitem(child); } additemtodumbcombobox(document.getelementbyid("cbcompany"), "new item #1"); additemtodumbcombobox(document.getelementbyid("cbcompany"), "new item #2"); additemtodumbcombobox(document.getelementbyid("cbcompany"), "new item #3"); </script>
... , see happens. note didn't test code, it's example.
btw, recomend switch combobox implementation decent javascript interface.
having server job buying toaster , every breakfast mailing factory, along 2 slices of bread, have them toasting , return toasts... it's dumb, don't blame yourself, that's common asp.net anti-pattern.
hope helps, , god bless!
Comments
Post a Comment