• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

My Javascript/jQuery code no longer working after I break up the page into Materpage and content page

Hi, I'm using asp.net 3.5 and C#
Attached is the Master and content page files and the original page when they're all together.  Can someone see what's wrong that cause the code not to work anymore?  thanks.
AddNewPatient.aspx
AddNewPatient.aspx.cs
ManageAccounts.aspx
ManageAccounts.aspx.cs
MasterPage.master
MasterPage.master.cs
0
lapucca
Asked:
lapucca
  • 4
  • 2
2 Solutions
 
stergiumCommented:
hello. i guess your problem is in the addnewpatient.aspx.
have you tried declaring the jquery paths there also?
this is my first quick  observation. when i have to hunt down javascript errors a good way for me is firefox with firebug installed. it usually gives me a good idea of what is wrong.
hope that helps
0
 
lapuccaAuthor Commented:
Hi, Yes, i did try adding the jquery links path in addnewpatient.aspx in the Head content section (<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">)
I also did installed the Firebug and when I select items in the 2 selectbox that supposed to triger the javascript/jquery code and I saw no error there either.  
Thank you.
0
 
chandrasekar1Commented:
Please update the following code in Masterpage.master and try

  <title>Adapt Survey Administration</title>
    <link href="~/CSS/AdaptStyle.css" rel="stylesheet" type="text/css" />
    <link href="~/CSS/superfish.css" rel="stylesheet" type="text/css" />
    
    <script src="../jQuery/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="../jQuery/superfish-1.4.8/js/hoverIntent.js" type="text/javascript"></script>
    <script src="../jQuery/superfish-1.4.8/js/superfish.js" type="text/javascript"></script>

Open in new window


and also remove the ScriptManager from master page and place it in content pages where ever you needed. this will improve the performance little.

 <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </asp:ToolkitScriptManager>

Open in new window

0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
lapuccaAuthor Commented:
Thank you for the performance tip on the ToolkitScriptManager.  

I removed the actualy script code from the Master pager and modified the script ref as follow.  In the content page I only added the toolscriptmanger.  the jQuery code was already at the content page in the ContentPlaceHolderID="head" section.   I'm attaching these 2 files so you can see them.

I ran the program and got error in the Firebug using the "~'.  It says '$' is not defined.  I think it's not able to find jQuery ref.  I changed to use "..' but then no error and nothing happens.  Please have another at why my code isn't working.  thank you.
//With this I got $ is not defined error
<head runat="server">
    <title>Adapt Survey Administration</title>
    <link href="~/CSS/AdaptStyle.css" rel="stylesheet" type="text/css" />
    <link href="~/CSS/superfish.css" rel="stylesheet" type="text/css" />
    <link href="~/CSS/superfish.css" rel="stylesheet" type="text/css" />
    <script src="~/jQuery/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="~/jQuery/superfish-1.4.8/js/hoverIntent.js" type="text/javascript"></script>
    <script src="~/jQuery/superfish-1.4.8/js/superfish.js" type="text/javascript"></script>
    


//With this I get no error but also nothing happens
<head runat="server">
    <title>Adapt Survey Administration</title>
    <link href="~/CSS/AdaptStyle.css" rel="stylesheet" type="text/css" />
    <link href="~/CSS/superfish.css" rel="stylesheet" type="text/css" />
    <script src="../jQuery/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="../jQuery/superfish-1.4.8/js/hoverIntent.js" type="text/javascript"></script>
    <script src="../jQuery/superfish-1.4.8/js/superfish.js" type="text/javascript"></script>

Open in new window

0
 
stergiumCommented:
a maybe silly suggestion but i have to write it.
Have you tried setting all the files into one folder  folder and after declaring the jquery run a $('some element').hide(); on $(document).ready(function () { }
  to check that jquery is working (or loaded). my guess is that it is not loaded or its loaded twice (in which case you should correct that).
i hope that made some sense!
0
 
lapuccaAuthor Commented:
Chandra,
Why I ref the CSS folder using .. and ~ when ref jQuery?  I tried using ~ for jQuery then I get error.  Or using .. for CSS folder I also get error.  The Master page is in the solution root in the tree.  The CSS and jQuery folders are off the root of the tree.  Why can't I just ~ for ref both folders?

I figure out why my jQuery code not working.  When jQuery is done in Master/content then jQuery cannot ref the name of a asp.net web control any more.  #lsAPExerciseOptions and #lbOtherExercise....  are no longer valid.  However, I can't remember how to ref each web control any more in jQuery when Master/content pages are at play.  Do anyone of you know how to do this?  Thanks.
0
 
lapuccaAuthor Commented:
Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now