Solved

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

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

810 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