Solved

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

Posted on 2011-09-11
4
291 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 35

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 35

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now