Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 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 June 5th, 2005, 07:26 PM
Registered User
 
Join Date: Apr 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Combining Javascript and ASP

I have a set of Fireworks generated, Javascripted pop-out navigation menus and I am trying to replace the ststic menu items with data from a database.
What is a good way to do this? Is there a program out there that helps with developing dynamic pop-out website navigation menu? I am rather surprised Fireworks does not provide an option like that. Please help.

Thanks,

- Chuksted

 
Old June 7th, 2005, 12:59 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

It does seem that the "neat-o user experience" development tools stay on the opposite side of the street from the "database application" development tools. I thinks it's a Jets vs. Sharks thing.

Usually what I do is let a UI tool build me a neat-o thingama-jig, then I take the generated, static HTML, figure out what repeats and build my own database-enabled control from it.

-Peter
 
Old June 7th, 2005, 03:25 PM
Registered User
 
Join Date: Apr 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yeah, I did that then I re-built the generated HTML file using Dreamweaver(ASP-JavaScript instead of ASP-VBScript) including data from DB. Everything worked fine untill I included the navigation file in the index.asp template.
Just as I suspected it might, errors were generated: the navigation file was built in ASP-Javascript and the index.asp file was built in ASP-VBScript (I could Declare only one page language in the index file: <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%> or <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>) that includes the navigation file.
Now, I guess I have to either figure a way to rebuild the navigation file again using ASP-VBScript or rebuild the index.asp file using ASP-Javascript.
It took me a while but I am glad I figured this out. I would still like to locate a tool to build dynamic navigation pop out menus more rapidly, please help somebody.

Thanks,
-Chuksted

 
Old June 12th, 2005, 02:54 AM
Authorized User
 
Join Date: May 2004
Posts: 83
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes, you can use only one scripting language in an ASP page on the server side. A default language can be specified for an entire set by setting its properties in the IIS Web Site Properties dialgo box. To set a default language for you site, open IIS. Right-click your web site and select P[u]r</u>operties. On the Properties dialog box, clik the Confi[u]g</u>uration... button to open Application Configuration dialog box. On the Options tab set the Default ASP [u]l</u>anguage to a value of your choice, for example VBScript. This way you need not to specify a language directive at the top of every page.

Besides, you can use multiple scripting languages in the Global.asp file. You'll need to surround your script with code like the following (change value of the language attribute to your choice):
Code:
<script language="vbscript" runat="server">
   ' your code goes here in the specified language 
</script>
Similiarly, on the client side, you can use ifferent scripting languages by enclosing you script in the
Code:
script
tag:
Code:
<script language="javascipt">
</script>

Regards,


ejan
 
Old June 15th, 2005, 01:37 PM
Authorized User
 
Join Date: May 2004
Posts: 83
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi all,

In my previous post, I wrote we could use only one scripting language in ASP. By chance, I discovered that it's not correct! Yes, you CAN use multiple languages in an ASP page. Before I go into how, please accept my apologies for what I wrote previosuly. Please be noted, however, that all else stated in that previous post was perfectly okay.

So how do you do that? Well, using different scripting languages in an ASP page is just a matter of enclosing your script in server-side <script> tag. The following code describes how you can combine VBScript and JavaScript code in an ASP page:

Code:
<script language="vbscript" runat="server">
    Response.Write "This is VBScript-generated response."
    ' Other code goes here...
</script>

<!-- Some HTML code 
.
.
.
-->

<script language="javascript" runat="server">
    Response.Write("This is JavaScript-generated response.");
    // Other code goes here...
</script>
Notice the runat="server" attribute of the script tag. It specifies that the code is to be run at the server, not the client.

Another important thing to be aware of is the scope of variables defined in these server-side script blocks. A variable declared in VBScipt-based server-side code block is not visible to code in JavaScript-based server-side code block and vice versa.

Regards,

ejan
 
Old June 16th, 2005, 10:25 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Quote:
quote:Originally posted by ejan
 Another important thing to be aware of is the scope of variables defined in these server-side script blocks. A variable declared in VBScipt-based server-side code block is not visible to code in JavaScript-based server-side code block and vice versa.

This is not true. Variables CAN be seen across this language boundary. However, there is one important catch: the ASP engine processes all JavaScript server script first, then the VBScript. (This might be configurable in the IIS settings, I'm not sure.) Therefore, variables defined first in ASP/JavaScript are visible in ASP/VBScript. The reverse is not true. So you have to declare vars in ASP/JavaScript first then they can be seen by ASP/VBScript that follows. If you define methods in ASP/JavaScript for use in the VBScript code, you shouldn't have a problem mixing languages. However, if you try to do inline processing in two languages you could get yourself into problems because of ASP/JavaScript being processed first.

For example, the following code:

  <script runat="server" language="vbscript">
  Response.Write("Test from vbscript:<br>")
  </script>
  <script runat="server" language="javascript">
  Response.Write("Test from javascript:<br>")
  </script>

Which actually render:

  Test from javascript:
  Test from vbscript:

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining PHP and C++ Waffles C++ Programming 0 August 3rd, 2007 01:20 PM
Combining two Queries arholly Access 1 January 16th, 2007 06:40 PM
Problem combining PHP and JavaScript AlanB BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 February 5th, 2005 07:12 AM
Combining tables spraveens Access 2 December 29th, 2003 11:08 AM





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