Click here to Skip to main content
15,888,062 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

In my ASP.NET application. I have used JQuery Autocomplete for retrieving database values using Handlers(.ashx).

Now the problem is, i used "UpdatePanel" to avoid flickering on Postback. Now those Autocomplete textbox are lost its JQuery reference on each Postback hence i need to rebind those textbox with the corresponding JQuery reference(From my previous post i got it from an developer).

Reference : How to Enable JQuery Autocomplete textbox inside Gridview with UpdatePanel?[^] [^]


Hence i used the code

XML
<script type="text/javascript">

    $(function () //Object Expected Error here
    {
        initializer();
    });

    var prmInstance = Sys.WebForms.PageRequestManager.getInstance(); //"Undefined variable Sys" error here

    prmInstance.add_endRequest(function () { //"Null reference" error here
        //you need to re-bind your jquery events here
        initializer();
    });

    function initializer()
    {
        $("#<%=txtProductName.ClientID%>").autocomplete('Products.ashx');
    }
</script>



From the reference : http://forums.asp.net/p/1622254/4164277.aspx[^]

But i'm getting error "Object Expected" in very first line.

I'm beginner in JQuery.

Any help would be appreciated.
Posted

First thing I see is: the argument of jQuery dollar sign function ("$") is some code which looks like a function definition with missing function name.

It's hard to understand what did you mean by that. Maybe, something like
JavaScript
$(document).ready(function(){
  // Your code here
});


(See http://docs.jquery.com/How_jQuery_Works#jQuery:_The_Basics[^].)

—SA
 
Share this answer
 
v2
Comments
J.Karthick 17-Nov-11 2:43am    
you are correct...
Now i declare
"$(document).ready(function() {...}" Its works fine..
But now i got error in line

var prmInstance = Sys.WebForms.PageRequestManager.getInstance(); //"Undefined variable Sys" error here
Oakshan 29-Jul-13 7:48am    
Just wanted to say thanks for this code snippet. I was unable to get Jquery to work with an older web forms project that I was given until I pointed the reference to an external web site. It does beg the question of why are my internal links not working though.
RaisKazi 17-Nov-11 2:46am    
Existing syntax will also work by providing reference of latest JQuery.


<script language="javascript" type="text/javascript" src="http://code.jquery.com/jquery-1.7.min.js"></script>
<script type="text/javascript">

$(function ()
{
alert('Hi');
})

</script>
Sergey Alexandrovich Kryukov 29-Jul-13 10:18am    
You are welcome.
Good luck, call again.
—SA
J.Karthick 17-Nov-11 3:15am    
ya...thanks for your reply...your are corect

but still i have problem(without errors) in retrieve db values. My autocomplete textbox not shown up...
Either you haven't specified the reference of JQuery Or you are using older version of JQuery.

Add below latest JQuery file in your Project and specify it's reference in your Aspx Page.
http://code.jquery.com/jquery-1.7.min.js
 
Share this answer
 
Comments
J.Karthick 17-Nov-11 3:12am    
yes...You are correct

Now its not throw any erors but inside updatePanel my autocomplete textbox remain static :(
Its not shown up the list of db retrieved values....

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