Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 1st, 2004, 03:34 PM
Authorized User
 
Join Date: Jan 2004
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default jscript in an ascx file

good evening,

I am trying to include a jscript nav bar into a ascx page, but the ascx is refusing to show the jscript. The nav bar code works and the ascx element both work separatly, but I cant seem to combine them.

I dont even know if this can be done - I am assuming it is possible. All suggestions, as always, very very welcome!

Thanks,

Morris



 
Old April 3rd, 2004, 07:35 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Can we see code? Yes it can be done. I guess it just depends on how you are trying to do it.
 
Old April 3rd, 2004, 07:45 PM
Authorized User
 
Join Date: Jan 2004
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi, how are peter?

Thanks once again for helping me out - here is my code (no laughing please!)

Firstly, here is the code for the drop down ascx file:

<%@ Control Language="vb" AutoEventWireup="false" Codebehind="Header.ascx.vb" Inherits="CompModel.Header" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<TABLE id="Table1" style="BORDER-RIGHT: gray 1px solid; BORDER-TOP: gray 1px solid; BORDER-LEFT: gray 1px solid; BORDER-BOTTOM: gray 1px solid; HEIGHT: 72px" cellSpacing="0" cellPadding="0" width="100%" border="0">
    <TR bgColor="#6699ff">
        <TD class="Banner" vAlign="center" align="left" width="20%" height="50" bgColor="#6699ff">
            <img src="file:///C:\Documents and Settings\User\Desktop\logo.gif" style="WIDTH: 125px; HEIGHT: 105px" height="105" width="125">
        </TD>
        <td>

                <h3>
                    Header text goes here
                </h3>

        </td>
        <TD vAlign="bottom" align="right" width="70%" colSpan="1" height="50" rowSpan="1" bgColor="#6699ff">
        </TD>
    </TR>
    <TR>
        <TD class="bannernav" background="file:///C:\Inetpub\wwwroot\CompModel\Images\overall_banner _top_right.jpg" height="18">&nbsp;&nbsp;&nbsp;</TD>
        <TD vAlign="center" align="right" width="100%" height="18" background="file:///C:\Inetpub\wwwroot\CompModel\Images\overall_banner _top_right.jpg">
        </TD>
    </TR>
</TABLE>

Hope that you are able to follow that. Here is the code for the jscript.

        <script language="JavaScript" src="C:\Inetpub\wwwroot\CompModel\navcond.js"></script>
        <script language="JavaScript">
            var myNavBar1 = new NavBar(0);
            var dhtmlMenu;

            //define menu items (first parameter of NavBarMenu specifies main category width, second specifies sub category width in pixels)
            //add more menus simply by adding more "blocks" of same code below

            dhtmlMenu = new NavBarMenu(100, 0);
            dhtmlMenu.addItem(new NavBarMenuItem("Home", "http://localhost/compmodel/"));
            myNavBar1.addMenu(dhtmlMenu);

            dhtmlMenu = new NavBarMenu(100, 120);
            dhtmlMenu.addItem(new NavBarMenuItem("Employees", ""));
            dhtmlMenu.addItem(new NavBarMenuItem("Employee Home", "http://localhost/CompModel/employee/default.aspx"));
            dhtmlMenu.addItem(new NavBarMenuItem("Review Evaluations", "http://localhost/CompModel/employee/review.aspx"));
            dhtmlMenu.addItem(new NavBarMenuItem("Position Comparision", "http://localhost/CompModel/employee/anypos.aspx"));
            myNavBar1.addMenu(dhtmlMenu);

            dhtmlMenu = new NavBarMenu(110, 120);
            dhtmlMenu.addItem(new NavBarMenuItem("Evaluation", "http://localhost/compmodel/Evaluation/Evaluation.aspx"));
            myNavBar1.addMenu(dhtmlMenu);

            dhtmlMenu = new NavBarMenu(100, 150);
            dhtmlMenu.addItem(new NavBarMenuItem("Administration", "http://localhost/CompModel/Admin/Default.aspx"));
            myNavBar1.addMenu(dhtmlMenu);

            //set menu colors
            myNavBar1.setColors("#000000", "#000000", "#C0C0C0", "#ffffff", "#666666", "#000000", "#cccccc", "#ffffff", "#000080")

            var fullWidth;

            function init() {

            // Get width of window, need to account for scrollbar width in Netscape.

            fullWidth = getWindowWidth()
                - (isMinNS4 && getWindowHeight() < getPageHeight() ? 16 : 0);

            myNavBar1.resize(985);
            myNavBar1.create();
            myNavBar1.setzIndex(2);
            myNavBar1.moveTo(10, 125);
            }
        </script>

Hope this makes sense. Thanks again for helping out,

Morris


 
Old April 3rd, 2004, 08:12 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Is that javascript code actually in the ASCX file? I would assume that's where you have it. If it's in there, it should show up. I can't fathom why it wouldn't if the code is in the ASCX file unless it's wrapped inside something that's causing it not to show up.
 
Old April 3rd, 2004, 08:25 PM
Authorized User
 
Join Date: Jan 2004
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi there,

(are you noticing a trend?!)

I have tried to combine the files together but with no success. In an idea situation, i would like the navbar to appear in the bottom row of the acsx file, but it wont display.

I have tried it like this:

<%@ Register TagPrefix="uc1" TagName="navbar" Src="navbar.ascx" %>
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="Header.ascx.vb" Inherits="CompModel.Header" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
    <HEAD>
        <title>test Name</title>
        <meta content="JavaScript" name="vs_defaultClientScript">
        <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
        <meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
        <meta content="VisualStudio.HTML" name="ProgId">
        <meta content="Microsoft Visual Studio.NET 7.0" name="Originator">
        <script language="JavaScript" src="C:\Inetpub\wwwroot\CompModel\navcond.js"></script>
        <script language="JavaScript">

var myNavBar1 = new NavBar(0);
var dhtmlMenu;

//define menu items (first parameter of NavBarMenu specifies main category width, second specifies sub category width in pixels)
//add more menus simply by adding more "blocks" of same code below

dhtmlMenu = new NavBarMenu(100, 0);
dhtmlMenu.addItem(new NavBarMenuItem("Home", "http://localhost/compmodel/"));
myNavBar1.addMenu(dhtmlMenu);

dhtmlMenu = new NavBarMenu(100, 120);
dhtmlMenu.addItem(new NavBarMenuItem("Employees", ""));
dhtmlMenu.addItem(new NavBarMenuItem("Employee Home", "http://localhost/CompModel/employee/default.aspx"));
dhtmlMenu.addItem(new NavBarMenuItem("Review Evaluations", "http://localhost/CompModel/employee/review.aspx"));
dhtmlMenu.addItem(new NavBarMenuItem("Position Comparision", "http://localhost/CompModel/employee/anypos.aspx"));
myNavBar1.addMenu(dhtmlMenu);

dhtmlMenu = new NavBarMenu(110, 120);
dhtmlMenu.addItem(new NavBarMenuItem("Evaluation", "http://localhost/compmodel/Evaluation/Evaluation.aspx"));

myNavBar1.addMenu(dhtmlMenu);


dhtmlMenu = new NavBarMenu(100, 150);
dhtmlMenu.addItem(new NavBarMenuItem("Administration", "http://localhost/CompModel/Admin/Default.aspx"));

myNavBar1.addMenu(dhtmlMenu);

//set menu colors
myNavBar1.setColors("#000000", "#000000", "#C0C0C0", "#ffffff", "#666666", "#000000", "#cccccc", "#ffffff", "#000080")

//uncomment below line to center the menu (valid values are "left", "center", and "right"
//myNavBar1.setAlign("center")

var fullWidth;

function init() {

  // Get width of window, need to account for scrollbar width in Netscape.

  fullWidth = getWindowWidth()
    - (isMinNS4 && getWindowHeight() < getPageHeight() ? 16 : 0);

  myNavBar1.resize(935);
  myNavBar1.create();
  myNavBar1.setzIndex(2);
  myNavBar1.moveTo(10, 125);
}
        </script>
    </HEAD>
    <Body onload="init()">
    <TABLE id="Table1" style="BORDER-RIGHT: gray 1px solid; BORDER-TOP: gray 1px solid; BORDER-LEFT: gray 1px solid; WIDTH: 936px; BORDER-BOTTOM: gray 1px solid; HEIGHT: 120px" cellSpacing="0" cellPadding="0" width="936" border="0">
    <TR bgColor="#6699ff">
        <TD class="Banner" vAlign="center" align="left" width="20%" height="50" bgColor="#6699ff">
            <img src="file:///C:\Inetpub\wwwroot\images\logo.gif" style="WIDTH: 125px; HEIGHT: 105px" height="105" width="125">
        </TD>
        <td>

                <h3>
                    header text goes here
                </h3>

        </td>
        <TD vAlign="bottom" align="right" width="70%" colSpan="1" height="50" rowSpan="1" bgColor="#6699ff">
        </TD>
    </TR>
    <TR>

        <TD class="bannernav" height="18">&nbsp;&nbsp;&nbsp;</TD>
        <TD vAlign="center" align="right" width="100%" height="18">&nbsp;&nbsp;&nbsp;</TD>
        <td>
        </td>
    </TR>
</TABLE>
</body>
</HTML>

i have also tried including the nav bar as another user control within a user control, but it didnt seem to like that much either!

Thanks,

Morris

 
Old April 4th, 2004, 12:05 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Are you getting any kind of error? From what you have I don't immediately see anything wrong.

One thing that I did notice, though shouldn't cause a problem while you are developing at least is the local file path reference for the .js file.
<script language="JavaScript" src="C:\Inetpub\wwwroot\CompModel\navcond.js"></script>

This should really be a reference relative to the application.





Similar Threads
Thread Thread Starter Forum Replies Last Post
.ascx file comment tag?? hoouliganian BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 December 11th, 2006 04:23 AM
Reading a file from a server using jscript dzisaacs Classic ASP Basics 3 May 8th, 2006 09:06 AM
Can't save XMLDoc to a xml file using JScript induriprakash Javascript 2 May 13th, 2005 02:44 PM
CodeBehind for .ascx file isn't working lcsgeek General .NET 1 January 21st, 2005 03:50 PM
Using ascx file or include ajindal Classic ASP Components 1 October 6th, 2004 07:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.