Solved

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

Posted on 2011-09-11
4
297 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Generate Unique ID in VB.NET 21 135
ASP.net Moving Visual Studio 2015 project to 2017 2 68
Send parameters via datatable ajax call 4 44
Shared Service Environment 2 54
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Suggested Courses

738 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