Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to Call functions written in javascript file ?

Reply
Thread Tools

How to Call functions written in javascript file ?

 
 
=?Utf-8?B?TWF2ZXJpY2s=?=
Guest
Posts: n/a
 
      01-20-2005
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
 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      01-20-2005
What exactly doesn't work?

Eliyahu

"Maverick" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
 
rohit pachnanda
Guest
Posts: n/a
 
      01-20-2005
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 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
>.
>

 
Reply With Quote
 
=?Utf-8?B?TWF2ZXJpY2s=?=
Guest
Posts: n/a
 
      01-20-2005
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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

>
>
>

 
Reply With Quote
 
rohit
Guest
Posts: n/a
 
      01-20-2005
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" <(E-Mail Removed)> wrote

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

http://www.velocityreviews.com/forums/(E-Mail Removed)...
>> > 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

>>
>>
>>

>.
>

 
Reply With Quote
 
=?Utf-8?B?TWF2ZXJpY2s=?=
Guest
Posts: n/a
 
      01-20-2005
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" <(E-Mail Removed)> wrote

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

> (E-Mail Removed)...
> >> > 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
> >>
> >>
> >>

> >.
> >

>

 
Reply With Quote
 
=?Utf-8?B?TWF2ZXJpY2s=?=
Guest
Posts: n/a
 
      01-20-2005
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" <(E-Mail Removed)> wrote

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

> > (E-Mail Removed)...
> > >> > 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
> > >>
> > >>
> > >>
> > >.
> > >

> >

 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      01-20-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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

> >
> >
> >



 
Reply With Quote
 
rohit
Guest
Posts: n/a
 
      01-20-2005
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" <(E-Mail Removed)>

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

>> (E-Mail Removed)...
>> >> > 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
>> >>
>> >>
>> >>
>> >.
>> >

>>

>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Generally, are the programs written by C++ slower than written by C10% ? KaiWen C++ 102 09-14-2011 11:12 PM
Standalone .js file creates IE, and call javascript functions in thepage Zhiguo Javascript 1 12-10-2009 05:10 PM
How to call module functions inside class instance functions? beginner Python 7 08-19-2007 05:48 AM
please help me in distinguish redefining functions, overloading functions and overriding functions. Xiangliang Meng C++ 1 06-21-2004 03:11 AM
Re: Can a usercontrol written in C# be used in Web Forms that is written in VB.Net? Steve C. Orr, MCSD ASP .Net 1 08-24-2003 12:06 AM



Advertisments