I am trying to use a JQuery plugin, and everything works great until I add an
<asp:ScriptManager> to my page. I reference a couple of javascript files, and then I am trying to make an in-line call to the jquery plugin, but for some reason it doesn't do anything. Does anyone know what I am missing?
It works fine using standard html links with in-line script, however I would like to utilize AJAX for some other things on my page, therefore I do need the
ScriptManager? Any suggestions?
If you've got a ScriptManager object, you must be using AJAX. How are you adding the inline code to your page? Inline code generally works on a full page PostBack, which AJAX doesn't do.
Thank you for the repy. I read the article that you posted, and it makes sense, however it really never goes into the correct way to call javascript utilizing the scriptmanager. Any suggestion to how I might approach calling a javascript function during
the Page_Load event?
Thanks...
If my response is you're solution, then please return the favor by selecting me as the post answer.
I was trying to call the function by adding this inline jQuery script to the body of the page. It works fine on a regular html page, however in converting everything to asp.net I have hit a road block. What is the proper way to call this? Do I need to
add a statement to the server side code? Thanks for your help...
You don't need to include those scripts through the ScriptManager, since they don't interact with ASP.NET AJAX components or controls at all. Include them through regular <script src="..."></script> elements, even though there is a ScriptManager on the page.
However, as soon as I added the scriptmanager to my page, the above code stopped working. I therefore assumed that I needed to create script references to the files in the scriptmanager, rather than using regular script elements. Either way, I can't seem
to make any client side javascript work when the scriptmanager is on the page.
javascriptscriptmanager
If my response is you're solution, then please return the favor by selecting me as the post answer.
In the process of adding the ScriptManager, is it possible that your element with the ID jDrawer-1 might have changed IDs? Try viewing source on the ScriptManager version's HTML and verify that an element with that ID does exist.
JDL1475
Member
682 Points
150 Posts
jQuery Script stops working after adding AJAX ScriptManager
Aug 31, 2008 07:42 AM|LINK
I am trying to use a JQuery plugin, and everything works great until I add an <asp:ScriptManager> to my page. I reference a couple of javascript files, and then I am trying to make an in-line call to the jquery plugin, but for some reason it doesn't do anything. Does anyone know what I am missing? It works fine using standard html links with in-line script, however I would like to utilize AJAX for some other things on my page, therefore I do need the ScriptManager? Any suggestions?
<asp:ScriptManager ID="ScriptManager1" runat="server"> <Scripts> <asp:ScriptReference Path="~/js/jquery/jquery-1.2.6.min.js" /> <asp:ScriptReference Path="~/js/jquery/jquery.dimensions.min.js" /> <asp:ScriptReference Path="~/js/jquery/jquery.jDrawer.js" /> </Scripts> </asp:ScriptManager> <script language="javascript" type="text/javascript"> jQuery(document).ready(function() { $("#jDrawer-1").jDrawer(); }); </script> <ul id="jDrawer-1" style="display: none"> <li class="jDrawer-active"> <a href="index.aspx" mce_href="index.aspx"><img class="png" alt="Text" src="images/picture.png" mce_src="images/picture.png" /></a> <div class="jDrawer-handle"> <h3>Home Page</h3> <div class="jDrawer-divider"></div> <p>text...</p> <a href="index.aspx" mce_href="index.aspx">Click Here</a> </div> </li> </ul>javascript jquery scriptmanager jdrawer
Feel free to contact me up if you need a Web developer in Tucson
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: In-line script stops working after adding AJAX ScriptManager
Aug 31, 2008 11:53 AM|LINK
If you've got a ScriptManager object, you must be using AJAX. How are you adding the inline code to your page? Inline code generally works on a full page PostBack, which AJAX doesn't do.
See http://tech-review.org/blogs/.net_2.0/archive/2007/02/08/lets-talk-scriptmanger.aspx for more information.
NC...
JDL1475
Member
682 Points
150 Posts
Re: In-line script stops working after adding AJAX ScriptManager
Sep 01, 2008 05:53 AM|LINK
Thank you for the repy. I read the article that you posted, and it makes sense, however it really never goes into the correct way to call javascript utilizing the scriptmanager. Any suggestion to how I might approach calling a javascript function during the Page_Load event?
Thanks...
Feel free to contact me up if you need a Web developer in Tucson
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: In-line script stops working after adding AJAX ScriptManager
Sep 01, 2008 11:49 AM|LINK
You did not answer how you are adding the inline code to your page.
NC...
JDL1475
Member
682 Points
150 Posts
Re: In-line script stops working after adding AJAX ScriptManager
Sep 01, 2008 04:26 PM|LINK
Oh sorry,
I was trying to call the function by adding this inline jQuery script to the body of the page. It works fine on a regular html page, however in converting everything to asp.net I have hit a road block. What is the proper way to call this? Do I need to add a statement to the server side code? Thanks for your help...
<script language="javascript" type="text/javascript"> jQuery(document).ready(function() { $("#jDrawer-1").jDrawer(); }); </script>jQuery jDrawer
Feel free to contact me up if you need a Web developer in Tucson
gt1329a
All-Star
15377 Points
2501 Posts
ASPInsiders
MVP
Re: In-line script stops working after adding AJAX ScriptManager
Sep 02, 2008 12:57 AM|LINK
A guide to combining jQuery and ASP.NET: jQuery for the ASP.NET developer
JDL1475
Member
682 Points
150 Posts
Re: In-line script stops working after adding AJAX ScriptManager
Sep 02, 2008 04:59 AM|LINK
I originally had my page set up with regular script elements like this:
<script src="js/jquery/jquery-1.2.6.min.js" type="text/javascript"></script> <script src="js/jquery/jquery.dimensions.min.js" type="text/javascript"></script> <script src="js/jquery/jquery.jDrawer.js" type="text/javascript"></script> <script type="text/javascript"> jQuery(document).ready(function() { $("#jDrawer-1").jDrawer(); }); </script>However, as soon as I added the scriptmanager to my page, the above code stopped working. I therefore assumed that I needed to create script references to the files in the scriptmanager, rather than using regular script elements. Either way, I can't seem to make any client side javascript work when the scriptmanager is on the page.
javascript scriptmanager
Feel free to contact me up if you need a Web developer in Tucson
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: In-line script stops working after adding AJAX ScriptManager
Sep 02, 2008 12:15 PM|LINK
I'll defer to Encosia on this one as he knows a heck of a lot more on AJAX and JQuery than I do.
NC...
gt1329a
All-Star
15377 Points
2501 Posts
ASPInsiders
MVP
Re: In-line script stops working after adding AJAX ScriptManager
Sep 02, 2008 01:51 PM|LINK
A guide to combining jQuery and ASP.NET: jQuery for the ASP.NET developer
JDL1475
Member
682 Points
150 Posts
Re: In-line script stops working after adding AJAX ScriptManager
Sep 02, 2008 05:01 PM|LINK
Great thinking, but here is a copy of the top of the page source. Both ID's are the same:
<script type="text/javascript"> //<![CDATA[ Sys.WebForms.PageRequestManager._initialize('ctl00$ContentPlaceHolder1$ScriptManager1', document.getElementById('aspnetForm')); Sys.WebForms.PageRequestManager.getInstance()._updateControls([], [], [], 90); //]]> </script> <script src="js/jquery/jquery-1.2.6.min.js" type="text/javascript"></script> <script src="js/jquery/jquery.dimensions.min.js" type="text/javascript"></script> <script src="js/jquery/jquery.jDrawer.js" type="text/javascript"></script> <script type="text/javascript"> jQuery(document).ready(function() { $("#jDrawer-1").jDrawer(); }); </script> <div id="ctl00_ContentPlaceHolder1_pagewrapper"> <div id="ctl00_ContentPlaceHolder1_leftside"> <h1>left</h1> </div> <div id="ctl00_ContentPlaceHolder1_rightside"> <h1>right</h1> <div id="sidebar-a"> <div class="title-l"> <div class="title-r"> <div class="title"> <h3>Quick Links</h3> </div> </div> </div> <ul id="jDrawer-1" style="display: none"> <li class="jDrawer-active"> <a href="index.aspx"><img class="png" alt="Home Pic" src="images/building.png" /></a> <div class="jDrawer-handle"> <h3>Home</h3> <div class="jDrawer-divider"></div> <p>Some text...</p> <a href="index.aspx">Home</a> </div> </li>jquery scriptmanager
Feel free to contact me up if you need a Web developer in Tucson