473,395 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to Call functions written in javascript file ?

I want to group all the javascript functions into a file named MiscFunc.js in
a asp.net project.
========================================
e.g. In MiscFunc.js
function dummyFunc(var1, var2)
{
alert(var1 + var2);
}
========================================

This javascript function will be called when a asp button is clicked.
========================================
butSubmit.Attributes.Add("onclick", "dummyFunc('abc', 'dec'); ")
========================================

and i've already added statement in the following in the <head> block of HTML
========================================
<script language="javascript" src="MiscFunc.js"></script>
========================================

Of coz, the code i stated above does not work anyway.
Do anyone of you knows how to make it work ?
thx
Nov 19 '05 #1
8 2103
What exactly doesn't work?

Eliyahu

"Maverick" <Ma******@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com...
I want to group all the javascript functions into a file named MiscFunc.js in a asp.net project.
========================================
e.g. In MiscFunc.js
function dummyFunc(var1, var2)
{
alert(var1 + var2);
}
========================================

This javascript function will be called when a asp button is clicked.
========================================
butSubmit.Attributes.Add("onclick", "dummyFunc('abc', 'dec'); ")
========================================

and i've already added statement in the following in the <head> block of HTML ========================================
<script language="javascript" src="MiscFunc.js"></script>
========================================

Of coz, the code i stated above does not work anyway.
Do anyone of you knows how to make it work ?
thx

Nov 19 '05 #2
hi,
i hope it will work follow it....
in code behind:
Protected WithEvents but1 As
System.Web.UI.WebControls.Button
then,
on page_load add
butsubmit.Attributes.Add("onclick", "dummyFunc
('abc', 'dec')")
bye for now
rohit pachnanda
software engineer
-----Original Message-----
I want to group all the javascript functions into a file named MiscFunc.js ina asp.net project.
========================================
e.g. In MiscFunc.js
function dummyFunc(var1, var2)
{
alert(var1 + var2);
}
========================================

This javascript function will be called when a asp button is clicked.========================================
butSubmit.Attributes.Add("onclick", "dummyFunc ('abc', 'dec'); ")========================================

and i've already added statement in the following in the <head> block of HTML========================================
<script language="javascript" src="MiscFunc.js"></script>
========================================

Of coz, the code i stated above does not work anyway.
Do anyone of you knows how to make it work ?
thx
.

Nov 19 '05 #3
the code --->
*** butSubmit.Attributes.Add("onclick", "dummyFunc('abc', 'dec'); ") ***
doesn't work

it's no proble if that change to
butSubmit.Attributes.Add("onclick", "alert('dummyMsg'); ")

but i really want to how can i called the functions written in external
javascript file'

"Eliyahu Goldin" wrote:
What exactly doesn't work?

Eliyahu

"Maverick" <Ma******@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com...
I want to group all the javascript functions into a file named MiscFunc.js

in
a asp.net project.
========================================
e.g. In MiscFunc.js
function dummyFunc(var1, var2)
{
alert(var1 + var2);
}
========================================

This javascript function will be called when a asp button is clicked.
========================================
butSubmit.Attributes.Add("onclick", "dummyFunc('abc', 'dec'); ")
========================================

and i've already added statement in the following in the <head> block of

HTML
========================================
<script language="javascript" src="MiscFunc.js"></script>
========================================

Of coz, the code i stated above does not work anyway.
Do anyone of you knows how to make it work ?
thx


Nov 19 '05 #4
In code behind...
Protected WithEvents butsubmit As
System.Web.UI.WebControls.button
In page_load...
butSubmit.Attributes.Add("onclick", "dummyFunc
('abc', 'dec') ")
remove ;
-----Original Message-----
the code --->
*** butSubmit.Attributes.Add("onclick", "dummyFunc ('abc', 'dec'); ") ***doesn't work

it's no proble if that change to
butSubmit.Attributes.Add("onclick", "alert('dummyMsg'); ")

but i really want to how can i called the functions written in externaljavascript file'

"Eliyahu Goldin" wrote:
What exactly doesn't work?

Eliyahu

"Maverick" <Ma******@discussions.microsoft.com> wrote in message
news:040727BC-1148-4EC7-96B2- 1B**********@microsoft.com...
> I want to group all the javascript functions into a file named MiscFunc.js in
> a asp.net project.
> ========================================
> e.g. In MiscFunc.js
> function dummyFunc(var1, var2)
> {
> alert(var1 + var2);
> }
> ========================================
>
> This javascript function will be called when a asp
button is clicked. > ========================================
> butSubmit.Attributes.Add("onclick", "dummyFunc ('abc', 'dec'); ") > ========================================
>
> and i've already added statement in the following in the <head> block of HTML
> ========================================
> <script language="javascript"

src="MiscFunc.js"></script> > ========================================
>
> Of coz, the code i stated above does not work anyway.
> Do anyone of you knows how to make it work ?
> thx


.

Nov 19 '05 #5
did u try that ?
it doesn't work for me anyway.

"rohit" wrote:
In code behind...
Protected WithEvents butsubmit As
System.Web.UI.WebControls.button
In page_load...
butSubmit.Attributes.Add("onclick", "dummyFunc
('abc', 'dec') ")
remove ;
-----Original Message-----
the code --->
*** butSubmit.Attributes.Add("onclick", "dummyFunc

('abc', 'dec'); ") ***
doesn't work

it's no proble if that change to
butSubmit.Attributes.Add("onclick", "alert('dummyMsg'); ")

but i really want to how can i called the functions

written in external
javascript file'

"Eliyahu Goldin" wrote:
What exactly doesn't work?

Eliyahu

"Maverick" <Ma******@discussions.microsoft.com> wrote in message news:040727BC-1148-4EC7-96B2- 1B**********@microsoft.com... > I want to group all the javascript functions into a file named MiscFunc.js in
> a asp.net project.
> ========================================
> e.g. In MiscFunc.js
> function dummyFunc(var1, var2)
> {
> alert(var1 + var2);
> }
> ========================================
>
> This javascript function will be called when a asp button is clicked. > ========================================
> butSubmit.Attributes.Add("onclick", "dummyFunc ('abc', 'dec'); ") > ========================================
>
> and i've already added statement in the following in the <head> block of HTML
> ========================================
> <script language="javascript" src="MiscFunc.js"></script> > ========================================
>
> Of coz, the code i stated above does not work anyway.
> Do anyone of you knows how to make it work ?
> thx

.

Nov 19 '05 #6
I mean ... juz part of that work.
maybe i made a worse example out .....
thx guys ...

"Maverick" wrote:
did u try that ?
it doesn't work for me anyway.

"rohit" wrote:
In code behind...
Protected WithEvents butsubmit As
System.Web.UI.WebControls.button
In page_load...
butSubmit.Attributes.Add("onclick", "dummyFunc
('abc', 'dec') ")
remove ;
-----Original Message-----
the code --->
*** butSubmit.Attributes.Add("onclick", "dummyFunc

('abc', 'dec'); ") ***
doesn't work

it's no proble if that change to
butSubmit.Attributes.Add("onclick", "alert('dummyMsg'); ")

but i really want to how can i called the functions

written in external
javascript file'

"Eliyahu Goldin" wrote:

> What exactly doesn't work?
>
> Eliyahu
>
> "Maverick" <Ma******@discussions.microsoft.com> wrote

in message
> news:040727BC-1148-4EC7-96B2-

1B**********@microsoft.com...
> > I want to group all the javascript functions into a

file named MiscFunc.js
> in
> > a asp.net project.
> > ========================================
> > e.g. In MiscFunc.js
> > function dummyFunc(var1, var2)
> > {
> > alert(var1 + var2);
> > }
> > ========================================
> >
> > This javascript function will be called when a asp

button is clicked.
> > ========================================
> > butSubmit.Attributes.Add("onclick", "dummyFunc

('abc', 'dec'); ")
> > ========================================
> >
> > and i've already added statement in the following in

the <head> block of
> HTML
> > ========================================
> > <script language="javascript"

src="MiscFunc.js"></script>
> > ========================================
> >
> > Of coz, the code i stated above does not work anyway.
> > Do anyone of you knows how to make it work ?
> > thx
>
>
>
.

Nov 19 '05 #7
Do you get any error message? The code looks good to me. Make sure your file
is in the same directory with the page. There could be other errors in the
script file that prevent calling your function. Try to call it just from
client code, for example from body's onload event.

Eliyahu

"Maverick" <Ma******@discussions.microsoft.com> wrote in message
news:48**********************************@microsof t.com...
the code --->
*** butSubmit.Attributes.Add("onclick", "dummyFunc('abc', 'dec'); ") ***
doesn't work

it's no proble if that change to
butSubmit.Attributes.Add("onclick", "alert('dummyMsg'); ")

but i really want to how can i called the functions written in external
javascript file'

"Eliyahu Goldin" wrote:
What exactly doesn't work?

Eliyahu

"Maverick" <Ma******@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com...
I want to group all the javascript functions into a file named
MiscFunc.js in
a asp.net project.
========================================
e.g. In MiscFunc.js
function dummyFunc(var1, var2)
{
alert(var1 + var2);
}
========================================

This javascript function will be called when a asp button is clicked.
========================================
butSubmit.Attributes.Add("onclick", "dummyFunc('abc', 'dec'); ")
========================================

and i've already added statement in the following in the <head> block
of HTML
========================================
<script language="javascript" src="MiscFunc.js"></script>
========================================

Of coz, the code i stated above does not work anyway.
Do anyone of you knows how to make it work ?
thx


Nov 19 '05 #8
include file .js in same folder ok
i tried it on code behind in page_load
remove ;
it`s working it`s giving alert "abcdec"
-----Original Message-----
did u try that ?
it doesn't work for me anyway.

"rohit" wrote:
In code behind...
Protected WithEvents butsubmit As
System.Web.UI.WebControls.button
In page_load...
butSubmit.Attributes.Add("onclick", "dummyFunc
('abc', 'dec') ")
remove ;
>-----Original Message-----
>the code --->
>*** butSubmit.Attributes.Add("onclick", "dummyFunc

('abc', 'dec'); ") ***
>doesn't work
>
>it's no proble if that change to
>butSubmit.Attributes.Add("onclick", "alert ('dummyMsg'); ") >
>but i really want to how can i called the functions

written in external
>javascript file'
>
>"Eliyahu Goldin" wrote:
>
>> What exactly doesn't work?
>>
>> Eliyahu
>>
>> "Maverick" <Ma******@discussions.microsoft.com> wrote
in message
>> news:040727BC-1148-4EC7-96B2-

1B**********@microsoft.com...
>> > I want to group all the javascript functions into
a file named MiscFunc.js
>> in
>> > a asp.net project.
>> > ========================================
>> > e.g. In MiscFunc.js
>> > function dummyFunc(var1, var2)
>> > {
>> > alert(var1 + var2);
>> > }
>> > ========================================
>> >
>> > This javascript function will be called when a asp

button is clicked.
>> > ========================================
>> > butSubmit.Attributes.Add("onclick", "dummyFunc

('abc', 'dec'); ")
>> > ========================================
>> >
>> > and i've already added statement in the following
in the <head> block of
>> HTML
>> > ========================================
>> > <script language="javascript"

src="MiscFunc.js"></script>
>> > ========================================
>> >
>> > Of coz, the code i stated above does not work

anyway. >> > Do anyone of you knows how to make it work ?
>> > thx
>>
>>
>>
>.
>

.

Nov 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: chirs | last post by:
I am trying to understand a piece of code. In a javascrpit file, there is a function: function ItemStyle(){ var names=; addProps(this,arguments,names,true); }; In the html file, it calls...
5
by: Sue | last post by:
After finishing up my first quarter JavaScript on 12/12/03, I decided to improve character checking on my project. In my project I only had to do very basic validation. Therefore, I only had one...
39
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
7
by: priya.tweety | last post by:
How to call a js file from another js file?
7
by: Tim ffitch | last post by:
Hi I have created a VB dll file that contains common functions I use across various projects in VB, Access and Excel. Rather than have to code the functions in each I decided to use the dll...
10
by: bienwell | last post by:
Hi, I have a question about file included in ASP.NET. I have a file that includes all the Sub functions (e.g FileFunct.vb). One of the functions in this file is : Sub TestFunct(ByVal...
12
by: Iddo | last post by:
Hi, I am having a strange problem... I have an HTML file which has 2 script tags: 1) <script language="javascript" id="ABC" src="ABC.js" /> 2) <script id="general" language="javascript">...
6
by: pronerd | last post by:
Hi, I am trying to dynamically set an event handler across frames. I have no problems setting properties across frames doing something like parent.ToolMenuFrame.location.href =...
3
by: Angus | last post by:
I have a web page with a toolbar containing a Save button. The Save button can change contextually to be a Search button in some cases. Hence the button name searchsavechanges. The snippet of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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...

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.