either write a normal page with dropdown, button... but wrap whole thing inside updatepanel.... eveything will be asynchronous and you dont have change u r code too much
or... the button click event should be used to call javascript function... from where you have to call jquery ajax method of codebehind...
You should save the dictionary into session and use jquery ajax to read dictionary data using pagemethod and read session value. In the success method build your necessary HTML.
parthiv.kuba...
Member
110 Points
196 Posts
how to do this .... showing the values of selected item on the page without postback .
Nov 28, 2012 08:09 AM|LINK
hi...
On my page user can select item ...and there is add button .when user select item and add I add that item to dictionry abject ... or array...
when user click add button I want to show item from object on page withou postback to server .
I want to do this on client side but i have no idea about how to use javascript .
plz give me some sample code to do this ...
kedarrkulkar...
All-Star
34535 Points
5554 Posts
Re: how to do this .... showing the values of selected item on the page without postback .
Nov 28, 2012 08:19 AM|LINK
you have couple of options...
either write a normal page with dropdown, button... but wrap whole thing inside updatepanel.... eveything will be asynchronous and you dont have change u r code too much
or... the button click event should be used to call javascript function... from where you have to call jquery ajax method of codebehind...
http://encosia.com/using-jquery-to-consume-aspnet-json-web-services/
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
me_ritz
Star
9337 Points
1447 Posts
Re: how to do this .... showing the values of selected item on the page without postback .
Nov 28, 2012 08:24 AM|LINK
Check out these links -
http://jqueryfaqs.com/Questions/ASP.Net-CheckBoxList-Get-Checked-or-Selected-Items-Client-side-using-jQuery.aspx
http://techbrij.com/984/checkboxlist-jquery-asp-net-operations
asteranup
All-Star
30184 Points
4906 Posts
Re: how to do this .... showing the values of selected item on the page without postback .
Nov 28, 2012 09:11 AM|LINK
Gum
You should save the dictionary into session and use jquery ajax to read dictionary data using pagemethod and read session value. In the success method build your necessary HTML.
http://delicious.com/anupdg/session+pagemethod
Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog
raju dasa
Star
14412 Points
2452 Posts
Re: how to do this .... showing the values of selected item on the page without postback .
Nov 28, 2012 12:31 PM|LINK
Hi,
Try this JS code using KO.
<!DOCTYPE html> <html> <head> <script src="http://cloud.github.com/downloads/SteveSanderson/knockout/knockout-2.1.0.js"></script> <meta charset=utf-8 /> <title>JS Bin</title> <script> function KOViewModel(){ var self = this; self.items = ['','one','two','three']; self.val = '';// ko.observable(); self.showValue = function(){ document.getElementsByTagName("span")[0].innerHTML = self.val; }; } window.onload = function(){ ko.applyBindings(new KOViewModel()); } </script> </head> <body> <select data-bind="options:items, value:val"></select> <button data-bind="click:showValue">add</button> <span data-bind="text:val"></span> </body> </html>rajudasa.blogspot.com || blog@opera
RameshRajend...
Star
7983 Points
2099 Posts
Re: how to do this .... showing the values of selected item on the page without postback .
Nov 28, 2012 12:35 PM|LINK
If you have a select element that looks like this:
Running this code:
var e = document.getElementById("ddlViewBy"); var strUser = e.options[e.selectedIndex].value; Alert(strUser );Would make strUser be 2. If what you actually want is test2, then do this:
var e = document.getElementById("ddlViewBy"); var strUser = e.options[e.selectedIndex].text; Alert(strUser );Which would make strUser be test2