i bascially want to get the value of a variable from the codebehind to use in a javascript function for autocomplete….here is the function:
$(document).ready(function() {
$('.PONumbers').autocomplete(
{
source: function(request, response) {
$.ajax({
url: "../GenericHandlers/PONumber.ashx",
dataType: "json",
data: {
q: request.term,
userid:'622'
},
success: function(data) {
response(data);
}
});
},
minLength: 3
})
}).unbind("blur.autocomplete");
$("body:not(.ui-autocomplete)").live('click', function(){
$('.PONumbers').autocomplete("close");
});
Where i have the value ‘622’ is where i want the value from the codebehind….any suggstions?
Try exposing a property in the code-behind, and you should be able to access the value like this:
And in the code-behind:
Using Page Methods
You could probably leverage
PageMethodsfor this too:And on the client:
Here’s the article I took the above code from:
http://blogs.microsoft.co.il/blogs/gilf/archive/2008/10/04/asp-net-ajax-pagemethods.aspx
And here is another tutorial on
PageMethods:http://aspalliance.com/1922_PageMethods_In_ASPNET_AJAX