Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET jQuery
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
 
<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 16-Nov-11 21:12pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
 $(document).ready(function(){
   // Your code here
 });
 
(See http://docs.jquery.com/How_jQuery_Works#jQuery:_The_Basics[^].)
 
—SA
  Permalink  
v2
Comments
jkarthick1989 at 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 at 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 at 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 at 29-Jul-13 10:18am
   
You are welcome.
Good luck, call again.
—SA
jkarthick1989 at 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...
SAKryukov at 17-Nov-11 11:16am
   
OK, I think it can be a separate problem not seen from the present question; it can be a separate one.
If this particular bug is fixed, please accept the answer formally (green button) -- thanks.
--SA
jkarthick1989 at 22-Nov-11 2:00am
   
i did..
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
Comments
jkarthick1989 at 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)

  Print Answers RSS
0 CPallini 235
1 DamithSL 225
2 OriginalGriff 198
3 George Jonsson 170
4 Maciej Los 165
0 OriginalGriff 5,305
1 DamithSL 4,382
2 Maciej Los 3,760
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,901


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 17 Nov 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100