Re: How to include JavaScript in .aspx page

G

Guest

I need to call a Javascript finction when a user clicks on Submit button. In
the Submit button I am already using OnClick to call a VB sub that resides in
the code-behind file.

If I use the <script language="JavaScript" src="somefile.js"></script> to
include all my Javascript, how do I call a Javascript function then since I
am using OnClick to call a Sub.

Joe



Alvin Bruney said:
use an include file

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Joe said:
Hi,

I have a lot of JavaScript (about 90-100 lines) that I want to include in
the .aspx page. Can someone tell me what would be the most efficient way
to
do it? I am using VB.NET.

Thanks,

Joe
 
W

William F. Robertson, Jr.

You can not call javascript from a vbscript method. (or atleast I haven't
found it.)

I have a work around, it works, but might be the long way around, any other
ideas should post, I might change my implementation of it.

My vbscript calls the click method of a hidden control. The hidden
control's click handler calls javascript.

<input type="button" id="btnSubmit" name="btnSubmit" value="Submit" />
sub btnSubmit_OnClick()
' do stuff
document.all( "ctlCrossClick" ).click()
end sub

<input type="button" onclick="javascript: myJavascriptMethod()"
style="display: none;" />

function myJavascriptMethod()
{
//do stuff.
}

HTH,

bill

Joe said:
I need to call a Javascript finction when a user clicks on Submit button. In
the Submit button I am already using OnClick to call a VB sub that resides in
the code-behind file.

If I use the <script language="JavaScript" src="somefile.js"></script> to
include all my Javascript, how do I call a Javascript function then since I
am using OnClick to call a Sub.

Joe



Alvin Bruney said:
use an include file

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Joe said:
Hi,

I have a lot of JavaScript (about 90-100 lines) that I want to include in
the .aspx page. Can someone tell me what would be the most efficient way
to
do it? I am using VB.NET.

Thanks,

Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top