By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,956 Members | 1,457 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,956 IT Pros & Developers. It's quick & easy.

Include a jscript file in asp.net using vb

P: n/a
Hello,

I'm coding in VB and trying to include a jscript file. This will not
work because you can only use one language in asp.net. Is there a way
that I can use the jscript without having to convert it to VB? I heard
something about using a component..is this true? Options?

Thanks all!

Jul 26 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

You can mix and match languages via a user control.

Put your jscript in a user control such as jscriptest.ascx as shown below:

<%@ control classname="jscriptest" language="jscript" %>
<script runat="server">
function monthNum(value : Date) : int {
return value.getMonth() + 1;
}
function datetoString(value : Date) : String {
return monthNum(value)+ "/" +
value.getDate() + "/" +
value.getYear();
}
var dt = new Date();
</script>

<%
Response.Write("The month is " + monthNum(dt) +".<BR>\n");
Response.Write("Date is " + datetoString(dt) +".<BR>\n");
%>

Create a VB jscriptuse.aspx page and drop the user control onto it, as shown
below:

<%@ Page Language="VB" %>
<%@ register src="jscriptest.ascx" tagname="jscriptest" tagprefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>JScript</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<uc1:jscriptest id="Jscriptest1" runat="server" />
&nbsp;</div>
</form>
</body>
</html>

When you run the ASP.NET page, you get the content from the user control.
Perhaps this will give you the idea to expand on.

See more here:

http://msdn.microsoft.com/library/de...ng01222002.asp

Let us know how you make out?

Ken
Microsoft MVP [ASP.NET]
"Jer425" <pa*****@wwu.eduwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hello,

I'm coding in VB and trying to include a jscript file. This will not
work because you can only use one language in asp.net. Is there a way
that I can use the jscript without having to convert it to VB? I heard
something about using a component..is this true? Options?

Thanks all!

Jul 27 '06 #2

P: n/a
Thanks Ken, the user control worked perfectly after a little tweaking.

Jul 27 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.