I'm new to jQuery and I have been doing a lot of reading on the Internet on jQuery plus Asp.Net. I have come across different solutions/hacks on how to incorporate the two technologies and I wonder what the correct/easiest way is. Here's my problem:
I originally planned to use the Ajax control toolkit's slider control, but am now trying to move to a jQuery slider instead. How should I cause a postback (I want to update a gridview based on the new value) when the user sets another value from the slider?
pettrer
Participant
970 Points
469 Posts
correct way of getting postback from jQuery slider
Apr 23, 2012 08:16 AM|LINK
Hi all,
I'm new to jQuery and I have been doing a lot of reading on the Internet on jQuery plus Asp.Net. I have come across different solutions/hacks on how to incorporate the two technologies and I wonder what the correct/easiest way is. Here's my problem:
I originally planned to use the Ajax control toolkit's slider control, but am now trying to move to a jQuery slider instead. How should I cause a postback (I want to update a gridview based on the new value) when the user sets another value from the slider?
Here's the slider demo url: http://jqueryui.com/demos/slider/#steps
Here's the slider code:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI Slider - Snap to increments</title> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> <script src="../../jquery-1.7.2.js"></script> <script src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.mouse.js"></script> <script src="../../ui/jquery.ui.slider.js"></script> <link rel="stylesheet" href="../demos.css"> <style> #demo-frame > div.demo { padding: 10px !important; }; </style> <script> $(function() { $( "#slider" ).slider({ value:100, min: 0, max: 500, step: 50, slide: function( event, ui ) { $( "#amount" ).val( "$" + ui.value ); } }); $( "#amount" ).val( "$" + $( "#slider" ).slider( "value" ) ); }); </script> </head> <body>Love to all,
Pettrer, Sweden
breath2k
Contributor
2101 Points
821 Posts
Re: correct way of getting postback from jQuery slider
Apr 23, 2012 11:06 AM|LINK
You need to call the postback manually using javascript within the slide function of the slider, i.e. after
See here on how to do this: http://www.dotnetspider.com/resources/1521-How-call-Postback-from-Javascript.aspx
asteranup
All-Star
30184 Points
4906 Posts
Re: correct way of getting postback from jQuery slider
Apr 23, 2012 11:20 AM|LINK
Hi,
Subscrive the change event of the slider. In the change event call __dopostback like below-
http://www.delicious.com/anupdg/__doPostBack
Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog
pettrer
Participant
970 Points
469 Posts
Re: correct way of getting postback from jQuery slider
Apr 23, 2012 12:43 PM|LINK
Guys,
Thanks a lot for your swift replies!
/Pettrer