473,624 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using External JavaScript in VB.NET Web Application

74 New Member
I have an extern JavaScript file I've called "Utils.js".

It will eventually hold all of the common JavaScript functions used throughout the ASPX pages that make up my website. Right now this file contains one JavaScript function.

When I add the JavaScript function using
Expand|Select|Wrap|Line Numbers
  1. Me.Page.ClientScript.RegisterStartupScript(Page.GetType, "myFunction", stringBuilderContainingMyScript.ToString())
I am able to use my function and everything works happily.
This method writes my script to the browser and because there are a lot of little scripts my HTML is getting rather bloated.

After placing this Script into an external JavaScript file I tried using
Expand|Select|Wrap|Line Numbers
  1. Me.Page.ClientScript.RegisterClientScriptInclude("__Utils", "Utils.js")
  2.  
However when I try to use the function in the external JS file I get a JavaScript error:
Object expected

It seems that when I call the JavaScript function, it does not exist.

Does anyone know how to fix this?

Thanks for your help!
-LilOlMe
Jul 13 '07 #1
5 3647
kenobewan
4,871 Recognized Expert Specialist
Is the .js file in the same directory?
Jul 14 '07 #2
lilOlMe
74 New Member
Is the .js file in the same directory?
The .js file is in the root directory of the web application.
Jul 16 '07 #3
lilOlMe
74 New Member
Is the .js file in the same directory?
Thanks for your help Kenobewan!

You were right in suggesting that I hadn't referred it correct.

The ASPX page that uses the .js file is in a sub folder whereas the .js file was in the root directory. I had to refer to it using "../Utils.js".

Referring to it using "/Utils.js" and "~/Utils.js" doesn't work.

Do you know why?

-LilOlMe
Jul 16 '07 #4
kenobewan
4,871 Recognized Expert Specialist
That's not so much to with .net, is my understanding, but the standard reference back towards the root directory.
Jul 17 '07 #5
lilOlMe
74 New Member
That's not so much to with .net, is my understanding, but the standard reference back towards the root directory.
That is correct.

My question is how do you refer to the root directory of your project from a page within it?
Jul 17 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
4237
by: KS | last post by:
I have a folder where i got all my external javascript.js files saved. Using the external.js files in my .jsp files works fin by: <script language="JavaScript" src="/PlexSysWeb/javascript/disableObjekt.js"> </script><script language="JavaScript" src="/PlexSysWeb/javascript/respons.js"></script>
2
2379
by: sdvoranchik | last post by:
We have an application that contains links that run javascripts to create pages in a separate frame. When these links open an external site, it causes the javascripts to no longer function. When we modified the links that invoke the javascripts from: <a href=javascript: top.doSomething> text </a> To: <span onclick=javascript:top.doSomething> text </span> The javascripts worked properly. Any ideas on why this now works or other...
1
1892
by: sandyde2 | last post by:
Hi all, I am writing a java application as a mozilla extension. Because mozilla uses javascript for the frontend, i need the javascript to call my external java application and pass one parameter to it. but... how to do it? any idea? many thanks
6
2305
by: Nou Dadoun | last post by:
I'm currently developing an application in C++/MFC (Visual Studio 6, if that makes a difference) and I'd like to avoid the Windows style UI widgets and dialogs if at all possible. In fact, what I'd really like to do is use HTML/web pages as the user interface and invoke my application in the background to do the heavy lifting. I'm fairly well experienced with web pages and I've written a fair amount of JavaScript at one time or another...
2
1252
by: Matt Weaver | last post by:
I'm converting an application from VB6 to VB.NET. In the application, a page calls an external javascript file which is generated in ASP. I'm trying to do this in an ASPX page, but I can't figure out how to generate a page without HTML page pages (<HTML><HEAD><BODY>). How can I do this? TIA Matt Weaver
8
1982
by: Flip | last post by:
I have a website that's using Master pages (very cool). But when I put JS on there (to close the browser for example) coming from an external file, when I navigate away from the first page, the JS no longer works. Can someone explain why this is happening? How can I fix this so that the JS is generic enough to work on every aspx to be included in the external JS file? The external JS file looks like this right now function...
1
1896
by: john | last post by:
I'm trying to develop fast, simple, html-based front ends for some Windows application programs. My idea: 1. Use html forms to let users supply run parameters (title, run options, etc.) 2. When the user presses a submit button: a. The selected options for all the form fields are written to an external file (e.g., c:\project\input.txt)
11
1918
by: ktrw25 | last post by:
Hello, I'm using the Yahoo UI to create a Panel in a custom application. I use ajax to request html from a php page to create the panel. The php page echo's out the entire html page including the src for javascript (which is an external file) for the html page. The returned html is then made into a div with a z-index of 6 to make the panel. This panel has buttons that use functions from the javascript that was passed back from the php page. The...
3
7353
by: akristensen | last post by:
I am new to this site, so be patient if I do not ask the question correctly. Current Target Platform: Browser: MS IE, script language: Javascript (will use VBScript, but JS is preferred), External apps: MS Excel What I need to do: From a web page using javascript, I open a new Excel application and sheet, populate some information into it. After it is populated with some information, I need to run the "Solver..." option on the data in the...
0
8174
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8624
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7164
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4082
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1786
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1485
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.