Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > VS.NET 2002/2003
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 25th, 2004, 06:08 AM
Authorized User
 
Join Date: Nov 2003
Location: hyderabad, AndhraPradesh, India.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to koneruvijay
Default External JS Files

Hello Folks

I am trying to add external JS files But i am unable to access those files can u please tell whether the below piece of code is correct or not
<% If (Session("EmplLevel")=( "SE")and Session("sUserid")<>1005 and Session("sUserid")<>1080 ) Then %>
    <%Response.Write(Session("EmplLevel"))%>
    <tr>
        <td>
            <SCRIPT language=JavaScript type="text/javascript" src="dev2000/HRD/nts/SEMenuFile.js"></SCRIPT>
            <DIV id=menu style="LEFT: 1px; POSITION: absolute; TOP: 150px"></DIV>
        </td>
    </tr>
<% End If %>

Reply With Quote
  #2 (permalink)  
Old February 25th, 2004, 08:43 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

This looks fine to me. What is the error? Are you getting javascript errors? Could the problem be the URL? Is that URL relative to the ASP.NET application or is that URL relative to the server root?
Reply With Quote
  #3 (permalink)  
Old February 26th, 2004, 08:02 AM
Authorized User
 
Join Date: Nov 2003
Location: hyderabad, AndhraPradesh, India.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to koneruvijay
Default

Quote:
quote:Originally posted by planoie
 This looks fine to me. What is the error? Are you getting javascript errors? Could the problem be the URL? Is that URL relative to the ASP.NET application or is that URL relative to the server root?

Hello friend,
The url is a JScript file which is located on different virtual directory on the same server.I am not getting any javascript errors the only thing is JS file is a menu file which is not displaying in my .Net page.One more important thing this is a converted page from asp to asp.net.
Can u please tell me whether my script tag is correct or not?
The JS File contains The below matter please dont get confused...


//--------------------------menus--------------------------------------------------------------
var menublock=new Array() // no need to change this
var plus_i=0 // no need to change this

menublock[0]="verdana;"+ // font mainlink
             "1;"+ // fontsize mainlink
             "#00008B;"+ // fontcolor mainlink
             "1;"+ // fontweight mainlink, 1 means bold, 0 means normal
             "Verdana;"+ // font sublinks
             "1;"+ // fontsize sublinks
             "#483D8B;"+ // fontcolor sublinks
             "0;"+ // fontweight sublinks, 1 means bold, 0 means normal
             "Jobs/Tasks |#|;"+ // text|URL|target of mainlink
                "Add New Tasks| AddNewTask.asp;"+ // text|URL|target of first sublink
                "Submit Task Sheet| Displaytasksheet.asp;"+
                "Previous Day Task Sheet| PreviousDayTasksheet.asp;" +
                "Assigned Activity| SETask.asp;" +
                "Other Jobs of the Day|OtherJobs.asp;" +
                "Previous Day Jobs|Previousjobs.asp;"

menublock[1]="verdana;"+ // font mainlink
             "1;"+ // fontsize mainlink
             "#00008B;"+ // fontcolor mainlink
             "1;"+ // fontweight mainlink, 1 means bold, 0 means normal
             "Verdana;"+ // font sublinks
             "1;"+ // fontsize sublinks
             "#483D8B;"+ // fontcolor sublinks
             "0;"+ // fontweight sublinks, 1 means bold, 0 means normal
             "My Reports |#|;"+ // text|URL|target of mainlink
                "My Jobs| MyJobs.asp;"+ // text|URL|target of first sublink
                "My TS Report| MyTSReport.asp ;"+
                "Task Sheet Report| EmpTaskSheetReport.asp ;"+
                "Mark My Tour| MarkMyTour.asp?level=adm ;" +
                "Manage My Tour| ManageMyTour.asp ;"

menublock[2]="verdana;"+ // font mainlink
             "1;"+ // fontsize mainlink
             "#00008B;"+ // fontcolor mainlink
                         "1;"+ // fontweight mainlink, 1 means bold, 0 means normal
                         ";;;;"+ // leave it empty
             "Reserve Conference Hall| ConBook.asp ;" // text and URL of mainlink

menublock[3]="verdana;"+ // font mainlink
             "1;"+ // fontsize mainlink
             "#00008B;"+ // fontcolor mainlink
                         "1;"+ // fontweight mainlink, 1 means bold, 0 means normal
                         ";;;;"+ // leave it empty
             "Change Password| changePwd.asp ;" // text and URL of mainlink

menublock[6]="verdana;"+ // font mainlink
             "1;"+ // fontsize mainlink
             "#00008B;"+ // fontcolor mainlink
                         "1;"+ // fontweight mainlink, 1 means bold, 0 means normal
                         ";;;;"+ // leave it empty
             "Logout| LogoutProcess1072MACActual.asp target='_top';" // text and URL of mainlink

menublock[5]="verdana;"+ // font mainlink
             "1;"+ // fontsize mainlink
             "#00008B;"+ // fontcolor mainlink
                         "1;"+ // fontweight mainlink, 1 means bold, 0 means normal
                         ";;;;"+ // leave it empty
             "Library Books| DisplayBook.asp target='_top';" // text and URL of mainlink

menublock[4]="verdana;"+ // font mainlink
             "1;"+ // fontsize mainlink
             "#00008B;"+ // fontcolor mainlink
                         "1;"+ // fontweight mainlink, 1 means bold, 0 means normal
                         ";;;;"+ // leave it empty
             "Help| Help.doc target='new';" // text and URL of mainlink

// No need to change anything below
// ************************************************** ********************************

var menusplit
var urlsplit
var font_weight_main
var font_weight_sub
var font_weight_sub

var minusimg=new Image()
minusimg.src="m.gif"

var plusimg=new Image()
plusimg.src="p.gif"

var showsubmenus=new Array()
for (i=0;i<=menublock.length-1;i++) {
    showsubmenus[i]=-1
}

var plusminusimg=new Array()
for (i=0;i<=menublock.length-1;i++) {
    plusminusimg[i]=plusimg.src
}

function modi(visi)
{

//alert(visi);
//alert(showsubmenus[visi]);
//alert(showsubmenus[1]);

if(visi==0)
  {if(showsubmenus[1]==1)
    openandclose(1);
   if(showsubmenus[2]==1)
    openandclose(2);
   if(showsubmenus[3]==1)
    openandclose(3);
 }
if(visi==1)
  {if(showsubmenus[0]==1)
    openandclose(0);
   if(showsubmenus[2]==1)
    openandclose(2);
   //if(showsubmenus[3]==1)
    //openandclose(3);
 }

if(visi==2)
  {if(showsubmenus[0]==1)
   openandclose(0);
   if(showsubmenus[1]==1)
    openandclose(1);
   if(showsubmenus[3]==1)
    openandclose(3);
 }
if(visi==3)
  {if(showsubmenus[0]==1)
    openandclose(0);
   //if(showsubmenus[1]==1)
   // openandclose(1);
   if(showsubmenus[2]==1)
    openandclose(2);
 }

openandclose(visi);
}
function openandclose(visi) {

    showsubmenus[visi]=(-1)*showsubmenus[visi]
    var menucontent=""
    if (showsubmenus[visi]==1) {plusminusimg[visi]=minusimg.src}
    if (showsubmenus[visi]==-1) {plusminusimg[visi]=plusimg.src}
    menucontent+="<table border=0>"
    for (i=0;i<=menublock.length-1;i++) {
        menusplit=menublock[i].split(";")
        urlsplit=menusplit.split("|")
        if (menusplit[3]==1) {font_weight_main="<b>"}
        if (menusplit[3]==0) {font_weight_main=""}
        if (menusplit[7]==1) {font_weight_sub="<b>"}
        if (menusplit[7]==0) {font_weight_sub=""}
        menucontent+="<tr><td>"

       if (menusplit[9].length==0) {
            menucontent+="</td>"
            menucontent+="<td>"
            menucontent+=font_weight_main
            menucontent+="<a href="+urlsplit[1]+">"
            menucontent+=""
            menucontent+=urlsplit[0]
            menucontent+="</a></td></tr>"
            plus_i++
        }

        if (menusplit[9].length!=0) {
            var thismainmenu=i+plus_i
            menucontent+="<a href='javascript:modi("+i+")'>"
            menucontent+="<img src='"+plusminusimg[i]+"' border=0></a></td>"
            menucontent+="<td>"
            menucontent+=font_weight_main
            menucontent+="<a href='javascript:modi("+i+")'>"
            menucontent+=""
            menucontent+=urlsplit[0]
            menucontent+="</a></td></tr>"

            if (showsubmenus[i]==1) {
                for (ii=9;ii<=menusplit.length-1;ii++) {
                    urlsplit=menusplit[ii].split("|")
                    menucontent+="<tr><td></td><td>"
                    menucontent+=font_weight_sub
                    menucontent+="<a href="+urlsplit[1]+" >"
                    menucontent+=""
                    menucontent+=urlsplit[0]
                    menucontent+="</a></td></tr>"
                }
            }
        }
    }
    menucontent+="</table>"
    if (document.all) {
        menu.innerHTML=menucontent
    }
    if (document.layers) {
        document.menu.document.write(menucontent)
        document.menu.document.close()
    }
}


// - End of JavaScript - -->






Reply With Quote
  #4 (permalink)  
Old February 26th, 2004, 10:39 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Quote:
quote:Originally posted by koneruvijay
The url is a JScript file which is located on different virtual directory on the same server.
That would most likely be the problem then...

If the page being served is in a virtual directory like this:

http://myserver/myWebApp/thePage.aspx

and the JS file is here:

http://myserver/dev2000/HRD/nts/SEMenuFile.js

Then when "thePage.aspx" references that JS file using the string you have, the browser will try to get the file from here:

http://myserver/myWebApp/dev2000/HRD/nts/SEMenuFile.js

You simply need to change the JS file reference from relative to virtual by adding a single / at the beginning.

<SCRIPT language=JavaScript type="text/javascript" src="/dev2000/HRD/nts/SEMenuFile.js"></SCRIPT>

Now the browser will attempt to get the JS file from the path starting at the root of the server, which is where it really lives.

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #5 (permalink)  
Old February 27th, 2004, 07:28 AM
Authorized User
 
Join Date: Nov 2003
Location: hyderabad, AndhraPradesh, India.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to koneruvijay
Default

Hello Pano,
No i am unable to get i am getting error Please see to the above code of js file whether there is any mistake in that?

and here i am also giving my file please check whether i made mistake?

<script language="javascript">
function iso()
{
    url="../HRD/iso/temp.asp?value=0&userid=<%=Session("sUserID")%>"

    newWindow = window.open(url,"Temp","menubar=no,scrollbars=yes, resizable=0,width=800,height=550,left=0,top=0");

}
</script>

<table border="0" width="100%" align="left" valign="top" cellspacing="2" cellpadding="1">
    <tr>
        <td valign="top" nowrap align="right">


            <%=Session("EmpName")%>

        </td>
    </tr>
<% If Session("EmplLevel")= "Admin" Then %>
    <tr>
        <td>
            <SCRIPT language=JavaScript src="/dev2000/HRD/nts/SEMenuFile.js" Runst=Server></SCRIPT>
            <DIV id=menu style="LEFT: 1px; POSITION: absolute; TOP: 150px"></DIV>
        </td>
    </tr>
<% End If %>

<% If Session("EmplLevel")=( "PL") Then %>
    <%Response.Write(Session("EmplLevel"))%>

    <tr>
        <td>
            <SCRIPT language=JavaScript type="text/javascript" src="/dev2000/HRD/nts/SEMenuFile.js"></SCRIPT>
            <DIV id=menu style="LEFT: 1px; POSITION: absolute; TOP: 150px"></DIV>
        </td>
    </tr>
<% End If %>

<% If (Session("EmplLevel")=( "SE")and Session("sUserid")<>1005 and Session("sUserid")<>1080 ) Then %>
    <tr>
        <td>
            <SCRIPT language=JavaScript type="text/javascript" src="SEMenuFile.js"></SCRIPT>
            <DIV id=menu style="LEFT: 1px; POSITION: absolute; TOP: 150px"></DIV>
        </td>
    </tr>
<% End If %>
<% If Session("EmplLevel")=( "SE") and Session("sUserid")=1005 Then %>
    <tr>
        <td>
            <SCRIPT language=JavaScript src="/dev2000/HRD/nts/SEMenuFile.js"></SCRIPT>
            <DIV id=menu style="LEFT: 1px; POSITION: absolute; TOP: 150px"></DIV>
        </td>
    </tr>
<% End If %>

<% If Session("EmplLevel")=( "SE") and Session("sUserid")=1080 Then %>

    <tr>
        <td>
            <SCRIPT language=JavaScript src="/dev2000/HRD/nts/SEMenuFile.js"></SCRIPT>

            <DIV id=menu style="LEFT: 1px; POSITION: absolute; TOP: 150px"></DIV>

        </td>
    </tr>
<% End If %>

 </table>

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
External JS files Ben Horne Javascript 3 July 25th, 2008 02:00 AM
external.js not executed cyrus67 Javascript 2 November 17th, 2006 10:29 AM
refreshing external js file fs22 Javascript How-To 1 June 17th, 2004 05:02 PM
Advice on Dynamically assigning external js file fs22 Javascript 9 June 10th, 2004 05:26 PM
Dynamically assign external js file fs22 Javascript How-To 1 May 21st, 2004 05:22 PM



All times are GMT -4. The time now is 03:02 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.