Solved

where should I put my javascript code for my content page?

Posted on 2011-09-11
4
296 Views
Last Modified: 2012-05-12
Hi,
I put my javascript code in the head section in Master file but when I compile my content page gets error looking for a javascript code.  My question is do I leave my script ref to jQuery library in the Master page head section and put Javascript code as needed in each content page's content section for Master Head section?  Thanks.  I'm using asp.net 3.5

so, something like this would stay in the Mater page head section? <script src="../jQuery/jquery-1.5.1.min.js" type="text/javascript"></script> and
            $(document).ready(function() {
                $('ul.sf-menu').superfish();
            });

And then something specific Javascript function would be in the Content page, content section for the Master Head area,
    <script type="text/javascript" language="javascript">
        $(document).ready(function() {
            $("#lsAPExerciseOptions").click(function() {

                var found = false;
                $('#lsAPExerciseOptions :selected').each(function(i, selected) {
                    if (parseInt($(selected).val()) == 11) {
                        found = true;
                    }
                });

                if (found) {


Well, I re0arrange my code but I'm still getting error in the Content page that it cannot find the Javascript function,
Error      3      'ASP.admin_addnewpatient_aspx' does not contain a definition for 'lsAPDietOptions_SelectedIndexChanged' and no extension method 'lsAPDietOptions_SelectedIndexChanged' accepting a first argument of type 'ASP.admin_addnewpatient_aspx' could be found (are you missing a using directive or an assembly reference?)      C:\Projects\AdaptSurvey\Admin\AddNewPatient.aspx      141      
 
0
Comment
Question by:lapucca
  • 2
  • 2
4 Comments
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 36520207
Please check in cod behind that 'lsAPDietOptions_SelectedIndexChanged'  method is public.
Note: IF it does not solve issue please post method declaration(line 141)
0
 

Author Comment

by:lapucca
ID: 36520254
Hi, yeah you're right. It's in the code behind.  I made a mistake thinking it's javascript.
However, my question still remains.  I wonder how do I do Javascript ref and function in Master and Content pages.  Where do I put the jQuery ref and actual javascript furnction code?  In master or content page?  Thanks.
0
 
LVL 36

Expert Comment

by:Miguel Oz
ID: 36520715
Put the jQuery ref  in the master (only if all the content pages use it) and the actual javascript function code in the content.
0
 

Author Closing Comment

by:lapucca
ID: 36520831
Thank you.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question