473,487 Members | 2,452 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Can you call asp function in asp.net?

Kat
Hi Guys,

Maybe you can help me out. Our company is interested to do .NET for the
first time. Our product is ASP based. We don't want to convert all our
existing stuff to .NET but create new applications in .NET. We created a lot
of APIs which is located in "inc" files that is in ASP. Is it possible to
call an ASP function in my ASPX page? For instance, in my ASPX :

<%@Page Language="VB" Explicit="True" %>
<!-- Foo.inc-->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body>
<table>
<tr>
<td><% Response.write(test("Hello"))%></td>
</tr>
</table>
</body>
</html>

-------------

Foo.inc file:
<%
function test(ByRef strValue as string)
' convert singl;e quote into a pair of single quotes
test=replace(strValue,"'","''")
end function

%>
When I run my code I get the following error:

Compiler Error Message: BC30451: Name 'test' is not declared.
Can you guys help me out? Thank you!
Jul 21 '05 #1
5 1273
If the ASP code is 100% compative with the asp.net code model, then usre.

In this case, it is not. In asp.net, all functions need to be in <script
runat="server"> blocks. Only inline script can be in the <% %> blocks.

"Kat" <Ka*@discussions.microsoft.com> wrote in message
news:2C**********************************@microsof t.com...
Hi Guys,

Maybe you can help me out. Our company is interested to do .NET for the
first time. Our product is ASP based. We don't want to convert all our
existing stuff to .NET but create new applications in .NET. We created a lot of APIs which is located in "inc" files that is in ASP. Is it possible to
call an ASP function in my ASPX page? For instance, in my ASPX :

<%@Page Language="VB" Explicit="True" %>
<!-- Foo.inc-->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body>
<table>
<tr>
<td><% Response.write(test("Hello"))%></td>
</tr>
</table>
</body>
</html>

-------------

Foo.inc file:
<%
function test(ByRef strValue as string)
' convert singl;e quote into a pair of single quotes
test=replace(strValue,"'","''")
end function

%>
When I run my code I get the following error:

Compiler Error Message: BC30451: Name 'test' is not declared.
Can you guys help me out? Thank you!

Jul 21 '05 #2
Kat,

Some changes that I typed in this message, not checked

<script language="VB" runat=server>
function test(ByVal strValue as String) as String
' convert single quote into a pair of single quotes
return replace(strValue,"'","''")
End function
</script>

I hope this helps something?

Cor
Jul 21 '05 #3
Kat
Does that mean that I have to do that for every inc files? Our old product
that is written in ASP will also be using these functions also.

thanks in advance!

"Cor Ligthert" wrote:
Kat,

Some changes that I typed in this message, not checked

<script language="VB" runat=server>
function test(ByVal strValue as String) as String
' convert single quote into a pair of single quotes
return replace(strValue,"'","''")
End function
</script>

I hope this helps something?

Cor

Jul 21 '05 #4
What it means, is that you can't use the inc files in both apps.

If you are going to rewrite them, you might as well eliminate them, and use
inheritance to achieve the same effect as you are porting your app to
asp.net.

"Kat" <Ka*@discussions.microsoft.com> wrote in message
news:34**********************************@microsof t.com...
Does that mean that I have to do that for every inc files? Our old product that is written in ASP will also be using these functions also.

thanks in advance!

"Cor Ligthert" wrote:
Kat,

Some changes that I typed in this message, not checked

<script language="VB" runat=server>
function test(ByVal strValue as String) as String
' convert single quote into a pair of single quotes
return replace(strValue,"'","''")
End function
</script>

I hope this helps something?

Cor

Jul 21 '05 #5
Kat,

I tried to show you the in my opinion nicest version.

<script language="VB" runat=server>
'this is nicer in ASPX and than all your subs and functions inside that.
It is not needed you can keep your old ASP style. Adviced is as far as I
know to upgrade this when busy with it. Doing that than it is easier to go
to code behind in future. Than you can by the way in the VBNet 2002/2003
versions not use your Inc pages anymore. (I don't know how that is in 2005)

function test(ByVal strValue as String) as String

'This is in my opinion your error. You did not write the return type "as
String".
'ByValue is in VBNet/CSharp almost forever more efficient than ByRef
'A reason to use ByRef can when you create a new object inside the function

Return replace(strValue,"'","''")
'This I find myself much nicer, however when you want what you had than that
is no problem at all.

I hope this helps?

Cor
Jul 21 '05 #6

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

Similar topics

3
4013
by: JoeK | last post by:
Hey all, I am automating a web page from Visual Foxpro. I can control all the textboxes, radio buttons, and command buttons using syntax such as: ...
13
4096
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make...
5
6503
by: Kurt Van Campenhout | last post by:
Hi, I am trying to get/set Terminal server information in the active directory on a windows 2000 domain. Since the ADSI calls for TS don't work until W2K3, I need to do it myself. I'm fairly...
9
3259
by: CryptiqueGuy | last post by:
Consider the variadic function with the following prototype: int foo(int num,...); Here 'num' specifies the number of arguments, and assume that all the arguments that should be passed to this...
6
5880
by: RandomElle | last post by:
Hi there I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with...
0
7106
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
6967
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
7137
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
4874
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3076
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...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
600
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
267
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...

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.