| Home | Forums | Reviews | Articles | Register |
![]() |
| Thread Tools |
Rating:
|
|
|
|
| |
|
Karl Seguin
Guest
Posts: n/a
|
Make TestFunc shared and access it via
ClassName.TextFunc so, it would look like public class Utility public shared TestFunct(..) ... end function end class and you would use it like: Utility.TestFunct(...) Karl -- MY ASP.Net tutorials http://www.openmymind.net/ - New and Improved (yes, the popup is annoying) http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to come!) "bienwell" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)... > 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 strInput As String) > return (strInput & " test") > End Sub > > > I'd like to call this function in FileFunct.vb from another .ASPX file > like this : > > <%@ import Namespace="System" %> > <%@ import Namespace="System.Data" %> > > <html> > <head> > <title>Test page</title> > </head> > > <body> > <script runat="server" language="VB" scr="FileFunct.vb" > > > Sub Page_Load(s As Object, e As EventArgs) > Dim result=TestFunct("This is a string") > response.write("<BR>result ==> " & result) > End Sub > </script> > </body> > </html> > > I've got this error: > > Server Error in '/' Application. > ---------------------------------------------------------------------------- > ---- > > Compilation Error > Description: An error occurred during the compilation of a resource > required > to service this request. Please review the following specific error > details > and modify your source code appropriately. > > Compiler Error Message: BC30451: Name 'TestFunct' is not declared. > > Source Error: > > > Line 18: Sub Page_Load(s As Object, e As EventArgs) > Line 19: > Line 20: Dim result=TestFunct("This is a string") > Line 21: response.write("<BR>Result ==> " & Result) > Line 22: > > > I have a single .ASPX file and I don't use Visual studio. NET in this > case. > Can I do that ? > > Thanks in advance. > > |
|
||
|
||||
|
Kevin Spencer
Guest
Posts: n/a
|
You're not thinking fourth-dimensionally! (- Back to the Future)
Actually, you're not thinking Object-Orientationally. ASP.Net is object-oriented, and you'd better get acquainted with it, or you'll be visiting here almost daily, and writing crappy code until you do. Let me elaborate, if you will: Files are source code. Your application doesn't have files. It has classes. A file defines a class, but IS not a class. A class is a data type, and exists in the context of a running application. So, when you're talking about how your application works, the first thing you need to do is think about classes, not files. A file can contain one or MORE class definitions, and you need to get acquainted with classes to be successful with .Net. Classes are very important in .Net programming; Objects are made from classes, and classes provide encapsulation. Object-oriented programming can get pretty darned complex, and encapsulation can save you a lot of grief, by hiding those things which need hiding from those things that don't need them. If you have a file with a bunch of Subs and Functions in it, you need to create a class with Subs and Functions in it. These Subs and Functions can be Shared (meaning that they are singleton objects that don't require a class instance to operate), or they can be Instance (meaning that an instance of the class containing them must be created in order to use them). The advantage to Shared data and process is that it doesn't require a class instance, and is, in essence "global," available to the entire application. This is also the disadvantage of Shared data and process. Anything can get to it, and change it, and in a multi-threaded app (unlike VB 6, .net is multi-threaded), this can cause all sorts of problems. Unless you're familiar with the issues, I would stick with classes that require instantiation. Instantiation is the process of creating a copy (instance) of a class that is limited in its scope (availability), and is thread-safe. Once you create an instance of a class, you can access any Public or Friend (Friend is more protected than Public, but you shouldn't run into issues right away) members from any other class that references the instance. From your question, and the code you posted, I can see that you require a good bit more education and practice. I would recommend the .Net SDK, a free download from: http://www.microsoft.com/downloads/d...displaylang=en It is extremely important to know the difference between ASP and ASP.Net, between VBScript or VB 6, and VB.Net. The first are procedural, single-threaded, and easy to use for small applications. .Net is object-oriented, multi-threaded, and easy to use once you spend a great deal of time studying it, but incredibly hard to use if you don't. -- HTH, Kevin Spencer Microsoft MVP ..Net Developer Everybody picks their nose, But some people are better at hiding it. "bienwell" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)... > 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 strInput As String) > return (strInput & " test") > End Sub > > > I'd like to call this function in FileFunct.vb from another .ASPX file > like this : > > <%@ import Namespace="System" %> > <%@ import Namespace="System.Data" %> > > <html> > <head> > <title>Test page</title> > </head> > > <body> > <script runat="server" language="VB" scr="FileFunct.vb" > > > Sub Page_Load(s As Object, e As EventArgs) > Dim result=TestFunct("This is a string") > response.write("<BR>result ==> " & result) > End Sub > </script> > </body> > </html> > > I've got this error: > > Server Error in '/' Application. > ---------------------------------------------------------------------------- > ---- > > Compilation Error > Description: An error occurred during the compilation of a resource > required > to service this request. Please review the following specific error > details > and modify your source code appropriately. > > Compiler Error Message: BC30451: Name 'TestFunct' is not declared. > > Source Error: > > > Line 18: Sub Page_Load(s As Object, e As EventArgs) > Line 19: > Line 20: Dim result=TestFunct("This is a string") > Line 21: response.write("<BR>Result ==> " & Result) > Line 22: > > > I have a single .ASPX file and I don't use Visual studio. NET in this > case. > Can I do that ? > > Thanks in advance. > > |
|
||
|
||||
|
bienwell
Guest
Posts: n/a
|
Kevin,
Last time I put all the files in my application (project name) using Visual Studio.NET, declared a class (AClass) which has some functions, and saved them in a file (.vb file). My program worked fine when I called the function from my other .vb files (AClass.Function1, ...). My application was Object-Oriented well development. Now, I'd like to try another way : creating .ASPX file that contains VB.NET script, HTML and call one function from another .vb file without using Visual Studio.NET. Can I do that and How ? It's my question. "Kevin Spencer" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)... > You're not thinking fourth-dimensionally! (- Back to the Future) > > Actually, you're not thinking Object-Orientationally. > > ASP.Net is object-oriented, and you'd better get acquainted with it, or > you'll be visiting here almost daily, and writing crappy code until you do. > Let me elaborate, if you will: > > Files are source code. Your application doesn't have files. It has classes. > A file defines a class, but IS not a class. A class is a data type, and > exists in the context of a running application. So, when you're talking > about how your application works, the first thing you need to do is think > about classes, not files. A file can contain one or MORE class definitions, > and you need to get acquainted with classes to be successful with .Net. > > Classes are very important in .Net programming; Objects are made from > classes, and classes provide encapsulation. Object-oriented programming can > get pretty darned complex, and encapsulation can save you a lot of grief, by > hiding those things which need hiding from those things that don't need > them. > > If you have a file with a bunch of Subs and Functions in it, you need to > create a class with Subs and Functions in it. These Subs and Functions can > be Shared (meaning that they are singleton objects that don't require a > class instance to operate), or they can be Instance (meaning that an > instance of the class containing them must be created in order to use them). > The advantage to Shared data and process is that it doesn't require a class > instance, and is, in essence "global," available to the entire application. > This is also the disadvantage of Shared data and process. Anything can get > to it, and change it, and in a multi-threaded app (unlike VB 6, .net is > multi-threaded), this can cause all sorts of problems. Unless you're > familiar with the issues, I would stick with classes that require > instantiation. Instantiation is the process of creating a copy (instance) of > a class that is limited in its scope (availability), and is thread-safe. > > Once you create an instance of a class, you can access any Public or Friend > (Friend is more protected than Public, but you shouldn't run into issues > right away) members from any other class that references the instance. > > From your question, and the code you posted, I can see that you require a > good bit more education and practice. I would recommend the .Net SDK, a free > download from: > > http://www.microsoft.com/downloads/d...displaylang=en > > It is extremely important to know the difference between ASP and ASP.Net, > between VBScript or VB 6, and VB.Net. The first are procedural, > single-threaded, and easy to use for small applications. .Net is > object-oriented, multi-threaded, and easy to use once you spend a great deal > of time studying it, but incredibly hard to use if you don't. > > -- > HTH, > > Kevin Spencer > Microsoft MVP > .Net Developer > Everybody picks their nose, > But some people are better at hiding it. > > "bienwell" <(E-Mail Removed)> wrote in message > news:(E-Mail Removed)... > > 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 strInput As String) > > return (strInput & " test") > > End Sub > > > > > > I'd like to call this function in FileFunct.vb from another .ASPX file > > like this : > > > > <%@ import Namespace="System" %> > > <%@ import Namespace="System.Data" %> > > > > <html> > > <head> > > <title>Test page</title> > > </head> > > > > <body> > > <script runat="server" language="VB" scr="FileFunct.vb" > > > > > Sub Page_Load(s As Object, e As EventArgs) > > Dim result=TestFunct("This is a string") > > response.write("<BR>result ==> " & result) > > End Sub > > </script> > > </body> > > </html> > > > > I've got this error: > > > > Server Error in '/' Application. > > -------------------------------------------------------------------------- -- > > ---- > > > > Compilation Error > > Description: An error occurred during the compilation of a resource > > required > > to service this request. Please review the following specific error > > details > > and modify your source code appropriately. > > > > Compiler Error Message: BC30451: Name 'TestFunct' is not declared. > > > > Source Error: > > > > > > Line 18: Sub Page_Load(s As Object, e As EventArgs) > > Line 19: > > Line 20: Dim result=TestFunct("This is a string") > > Line 21: response.write("<BR>Result ==> " & Result) > > Line 22: > > > > > > I have a single .ASPX file and I don't use Visual studio. NET in this > > case. > > Can I do that ? > > > > Thanks in advance. > > > > > > |
|
||
|
||||
|
bienwell
Guest
Posts: n/a
|
Karl,
I've tried it like this: (In Function.vb file) Public Class EFiling_Funct Public Shared Function TestFunct(ByVal strInput As String) return (strInput & " test") End Function End Class ================================================ (in File1.ASPX file) <%@ import Namespace="System" %> <%@ import Namespace="System.Data" %> <html> <head> <title>Untitled</title> </head> <body> <script runat="server" language="VB" > Sub Page_Load(s As Object, e As EventArgs) Dim result=EFiling_Funct.TestFunct("This is a string") response.write("<BR>Result ==> " & Result) End Sub </script> </body> </html> and received this error message : Server Error in '/' Application. ---------------------------------------------------------------------------- ---- Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: BC30451: Name 'EFiling_Funct' is not declared. Source Error: Line 18: Sub Page_Load(s As Object, e As EventArgs) Line 19: Line 20: Dim result=EFiling_Funct.TestFunct("This is a string") Line 21: response.write("<BR>Result ==> " & Result) Line 22: "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:(E-Mail Removed)... > Make TestFunc shared and access it via > > ClassName.TextFunc > > so, it would look like > > public class Utility > public shared TestFunct(..) > ... > end function > end class > > and you would use it like: > > Utility.TestFunct(...) > > Karl > > -- > MY ASP.Net tutorials > http://www.openmymind.net/ - New and Improved (yes, the popup is > annoying) > http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to > come!) > "bienwell" <(E-Mail Removed)> wrote in message > news:(E-Mail Removed)... > > 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 strInput As String) > > return (strInput & " test") > > End Sub > > > > > > I'd like to call this function in FileFunct.vb from another .ASPX file > > like this : > > > > <%@ import Namespace="System" %> > > <%@ import Namespace="System.Data" %> > > > > <html> > > <head> > > <title>Test page</title> > > </head> > > > > <body> > > <script runat="server" language="VB" scr="FileFunct.vb" > > > > > Sub Page_Load(s As Object, e As EventArgs) > > Dim result=TestFunct("This is a string") > > response.write("<BR>result ==> " & result) > > End Sub > > </script> > > </body> > > </html> > > > > I've got this error: > > > > Server Error in '/' Application. > > -------------------------------------------------------------------------- -- > > ---- > > > > Compilation Error > > Description: An error occurred during the compilation of a resource > > required > > to service this request. Please review the following specific error > > details > > and modify your source code appropriately. > > > > Compiler Error Message: BC30451: Name 'TestFunct' is not declared. > > > > Source Error: > > > > > > Line 18: Sub Page_Load(s As Object, e As EventArgs) > > Line 19: > > Line 20: Dim result=TestFunct("This is a string") > > Line 21: response.write("<BR>Result ==> " & Result) > > Line 22: > > > > > > I have a single .ASPX file and I don't use Visual studio. NET in this > > case. > > Can I do that ? > > > > Thanks in advance. > > > > > > |
|
||
|
||||
|
tom pester
Guest
Posts: n/a
|
Hi Kevin,
This article is what you need when using asp.net 1.1 http://aspnet.4guysfromrolla.com/articles/122403-1.aspx It gest even simpler if you use asp.net v2. In this cas just drop the class file in the App_Code directory and you can call them everywhere. Let me know if you have any more questions... Cheers, Tom Pester > You're not thinking fourth-dimensionally! (- Back to the Future) > > Actually, you're not thinking Object-Orientationally. > > ASP.Net is object-oriented, and you'd better get acquainted with it, > or you'll be visiting here almost daily, and writing crappy code until > you do. Let me elaborate, if you will: > > Files are source code. Your application doesn't have files. It has > classes. A file defines a class, but IS not a class. A class is a data > type, and exists in the context of a running application. So, when > you're talking about how your application works, the first thing you > need to do is think about classes, not files. A file can contain one > or MORE class definitions, and you need to get acquainted with classes > to be successful with .Net. > > Classes are very important in .Net programming; Objects are made from > classes, and classes provide encapsulation. Object-oriented > programming can get pretty darned complex, and encapsulation can save > you a lot of grief, by hiding those things which need hiding from > those things that don't need them. > > If you have a file with a bunch of Subs and Functions in it, you need > to create a class with Subs and Functions in it. These Subs and > Functions can be Shared (meaning that they are singleton objects that > don't require a class instance to operate), or they can be Instance > (meaning that an instance of the class containing them must be created > in order to use them). The advantage to Shared data and process is > that it doesn't require a class instance, and is, in essence "global," > available to the entire application. This is also the disadvantage of > Shared data and process. Anything can get to it, and change it, and in > a multi-threaded app (unlike VB 6, .net is multi-threaded), this can > cause all sorts of problems. Unless you're familiar with the issues, I > would stick with classes that require instantiation. Instantiation is > the process of creating a copy (instance) of a class that is limited > in its scope (availability), and is thread-safe. > > Once you create an instance of a class, you can access any Public or > Friend (Friend is more protected than Public, but you shouldn't run > into issues right away) members from any other class that references > the instance. > > From your question, and the code you posted, I can see that you > require a good bit more education and practice. I would recommend the > .Net SDK, a free download from: > > http://www.microsoft.com/downloads/d...=9B3A2CA6-3647 > -4070-9F41-A333C6B9181D&displaylang=en > > It is extremely important to know the difference between ASP and > ASP.Net, between VBScript or VB 6, and VB.Net. The first are > procedural, single-threaded, and easy to use for small applications. > .Net is object-oriented, multi-threaded, and easy to use once you > spend a great deal of time studying it, but incredibly hard to use if > you don't. > > Kevin Spencer > Microsoft MVP > .Net Developer > Everybody picks their nose, > But some people are better at hiding it. > "bienwell" <(E-Mail Removed)> wrote in message > news:(E-Mail Removed)... > >> 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 strInput As String) >> return (strInput & " test") >> End Sub >> I'd like to call this function in FileFunct.vb from another .ASPX >> file like this : >> >> <%@ import Namespace="System" %> >> <%@ import Namespace="System.Data" %> >> <html> >> <head> >> <title>Test page</title> >> </head> >> <body> >> <script runat="server" language="VB" scr="FileFunct.vb" > >> Sub Page_Load(s As Object, e As EventArgs) >> Dim result=TestFunct("This is a string") >> response.write("<BR>result ==> " & result) >> End Sub >> </script> >> </body> >> </html> >> I've got this error: >> >> Server Error in '/' Application. >> --------------------------------------------------------------------- >> ------- ---- >> >> Compilation Error >> Description: An error occurred during the compilation of a resource >> required >> to service this request. Please review the following specific error >> details >> and modify your source code appropriately. >> Compiler Error Message: BC30451: Name 'TestFunct' is not declared. >> >> Source Error: >> >> Line 18: Sub Page_Load(s As Object, e As EventArgs) >> Line 19: >> Line 20: Dim result=TestFunct("This is a string") >> Line 21: response.write("<BR>Result ==> " & Result) >> Line 22: >> I have a single .ASPX file and I don't use Visual studio. NET in this >> case. >> Can I do that ? >> Thanks in advance. >> |
|
||
|
||||
|
Kevin Spencer
Guest
Posts: n/a
|
Sorry dude, it may be all YOU need, but my requirements go a good bit
farther. -- HTH, Kevin Spencer Microsoft MVP ..Net Developer Everybody picks their nose, But some people are better at hiding it. "tom pester" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)... > Hi Kevin, > > This article is what you need when using asp.net 1.1 > > http://aspnet.4guysfromrolla.com/articles/122403-1.aspx > > It gest even simpler if you use asp.net v2. In this cas just drop the > class file in the App_Code directory and you can call them everywhere. > > Let me know if you have any more questions... > > Cheers, > Tom Pester > >> You're not thinking fourth-dimensionally! (- Back to the Future) >> >> Actually, you're not thinking Object-Orientationally. >> >> ASP.Net is object-oriented, and you'd better get acquainted with it, >> or you'll be visiting here almost daily, and writing crappy code until >> you do. Let me elaborate, if you will: >> >> Files are source code. Your application doesn't have files. It has >> classes. A file defines a class, but IS not a class. A class is a data >> type, and exists in the context of a running application. So, when >> you're talking about how your application works, the first thing you >> need to do is think about classes, not files. A file can contain one >> or MORE class definitions, and you need to get acquainted with classes >> to be successful with .Net. >> >> Classes are very important in .Net programming; Objects are made from >> classes, and classes provide encapsulation. Object-oriented >> programming can get pretty darned complex, and encapsulation can save >> you a lot of grief, by hiding those things which need hiding from >> those things that don't need them. >> >> If you have a file with a bunch of Subs and Functions in it, you need >> to create a class with Subs and Functions in it. These Subs and >> Functions can be Shared (meaning that they are singleton objects that >> don't require a class instance to operate), or they can be Instance >> (meaning that an instance of the class containing them must be created >> in order to use them). The advantage to Shared data and process is >> that it doesn't require a class instance, and is, in essence "global," >> available to the entire application. This is also the disadvantage of >> Shared data and process. Anything can get to it, and change it, and in >> a multi-threaded app (unlike VB 6, .net is multi-threaded), this can >> cause all sorts of problems. Unless you're familiar with the issues, I >> would stick with classes that require instantiation. Instantiation is >> the process of creating a copy (instance) of a class that is limited >> in its scope (availability), and is thread-safe. >> >> Once you create an instance of a class, you can access any Public or >> Friend (Friend is more protected than Public, but you shouldn't run >> into issues right away) members from any other class that references >> the instance. >> >> From your question, and the code you posted, I can see that you >> require a good bit more education and practice. I would recommend the >> .Net SDK, a free download from: >> >> http://www.microsoft.com/downloads/d...=9B3A2CA6-3647 >> -4070-9F41-A333C6B9181D&displaylang=en >> >> It is extremely important to know the difference between ASP and >> ASP.Net, between VBScript or VB 6, and VB.Net. The first are >> procedural, single-threaded, and easy to use for small applications. >> .Net is object-oriented, multi-threaded, and easy to use once you >> spend a great deal of time studying it, but incredibly hard to use if >> you don't. >> >> Kevin Spencer >> Microsoft MVP >> .Net Developer >> Everybody picks their nose, >> But some people are better at hiding it. >> "bienwell" <(E-Mail Removed)> wrote in message >> news:(E-Mail Removed)... >> >>> 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 strInput As String) >>> return (strInput & " test") >>> End Sub >>> I'd like to call this function in FileFunct.vb from another .ASPX >>> file like this : >>> >>> <%@ import Namespace="System" %> >>> <%@ import Namespace="System.Data" %> >>> <html> >>> <head> >>> <title>Test page</title> >>> </head> >>> <body> >>> <script runat="server" language="VB" scr="FileFunct.vb" > >>> Sub Page_Load(s As Object, e As EventArgs) >>> Dim result=TestFunct("This is a string") >>> response.write("<BR>result ==> " & result) >>> End Sub >>> </script> >>> </body> >>> </html> >>> I've got this error: >>> >>> Server Error in '/' Application. >>> --------------------------------------------------------------------- >>> ------- ---- >>> >>> Compilation Error >>> Description: An error occurred during the compilation of a resource >>> required >>> to service this request. Please review the following specific error >>> details >>> and modify your source code appropriately. >>> Compiler Error Message: BC30451: Name 'TestFunct' is not declared. >>> >>> Source Error: >>> >>> Line 18: Sub Page_Load(s As Object, e As EventArgs) >>> Line 19: >>> Line 20: Dim result=TestFunct("This is a string") >>> Line 21: response.write("<BR>Result ==> " & Result) >>> Line 22: >>> I have a single .ASPX file and I don't use Visual studio. NET in this >>> case. >>> Can I do that ? >>> Thanks in advance. >>> > > |
|
||
|
||||
|
Kevin Spencer
Guest
Posts: n/a
|
I'm afraid anything but Best Practices is outside of my purview.
-- HTH, Kevin Spencer Microsoft MVP ..Net Developer Everybody picks their nose, But some people are better at hiding it. "bienwell" <(E-Mail Removed)> wrote in message news:eu$(E-Mail Removed)... > Kevin, > > Last time I put all the files in my application (project name) using > Visual > Studio.NET, declared a class (AClass) which has some functions, and saved > them in a file (.vb file). My program worked fine when I called the > function > from my other .vb files (AClass.Function1, ...). My application was > Object-Oriented well development. Now, I'd like to try another way : > creating .ASPX file that contains VB.NET script, HTML and call one > function > from another .vb file without using Visual Studio.NET. Can I do that and > How > ? It's my question. > > > > > "Kevin Spencer" <(E-Mail Removed)> wrote in message > news:(E-Mail Removed)... >> You're not thinking fourth-dimensionally! (- Back to the Future) >> >> Actually, you're not thinking Object-Orientationally. >> >> ASP.Net is object-oriented, and you'd better get acquainted with it, or >> you'll be visiting here almost daily, and writing crappy code until you > do. >> Let me elaborate, if you will: >> >> Files are source code. Your application doesn't have files. It has > classes. >> A file defines a class, but IS not a class. A class is a data type, and >> exists in the context of a running application. So, when you're talking >> about how your application works, the first thing you need to do is think >> about classes, not files. A file can contain one or MORE class > definitions, >> and you need to get acquainted with classes to be successful with .Net. >> >> Classes are very important in .Net programming; Objects are made from >> classes, and classes provide encapsulation. Object-oriented programming > can >> get pretty darned complex, and encapsulation can save you a lot of grief, > by >> hiding those things which need hiding from those things that don't need >> them. >> >> If you have a file with a bunch of Subs and Functions in it, you need to >> create a class with Subs and Functions in it. These Subs and Functions >> can >> be Shared (meaning that they are singleton objects that don't require a >> class instance to operate), or they can be Instance (meaning that an >> instance of the class containing them must be created in order to use > them). >> The advantage to Shared data and process is that it doesn't require a > class >> instance, and is, in essence "global," available to the entire > application. >> This is also the disadvantage of Shared data and process. Anything can >> get >> to it, and change it, and in a multi-threaded app (unlike VB 6, .net is >> multi-threaded), this can cause all sorts of problems. Unless you're >> familiar with the issues, I would stick with classes that require >> instantiation. Instantiation is the process of creating a copy (instance) > of >> a class that is limited in its scope (availability), and is thread-safe. >> >> Once you create an instance of a class, you can access any Public or > Friend >> (Friend is more protected than Public, but you shouldn't run into issues >> right away) members from any other class that references the instance. >> >> From your question, and the code you posted, I can see that you require a >> good bit more education and practice. I would recommend the .Net SDK, a > free >> download from: >> >> > http://www.microsoft.com/downloads/d...displaylang=en >> >> It is extremely important to know the difference between ASP and ASP.Net, >> between VBScript or VB 6, and VB.Net. The first are procedural, >> single-threaded, and easy to use for small applications. .Net is >> object-oriented, multi-threaded, and easy to use once you spend a great > deal >> of time studying it, but incredibly hard to use if you don't. >> >> -- >> HTH, >> >> Kevin Spencer >> Microsoft MVP >> .Net Developer >> Everybody picks their nose, >> But some people are better at hiding it. >> >> "bienwell" <(E-Mail Removed)> wrote in message >> news:(E-Mail Removed)... >> > 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 strInput As String) >> > return (strInput & " test") >> > End Sub >> > >> > >> > I'd like to call this function in FileFunct.vb from another .ASPX >> > file >> > like this : >> > >> > <%@ import Namespace="System" %> >> > <%@ import Namespace="System.Data" %> >> > >> > <html> >> > <head> >> > <title>Test page</title> >> > </head> >> > >> > <body> >> > <script runat="server" language="VB" scr="FileFunct.vb" > >> > >> > Sub Page_Load(s As Object, e As EventArgs) >> > Dim result=TestFunct("This is a string") >> > response.write("<BR>result ==> " & result) >> > End Sub >> > </script> >> > </body> >> > </html> >> > >> > I've got this error: >> > >> > Server Error in '/' Application. >> >> -------------------------------------------------------------------------- > -- >> > ---- >> > >> > Compilation Error >> > Description: An error occurred during the compilation of a resource >> > required >> > to service this request. Please review the following specific error >> > details >> > and modify your source code appropriately. >> > >> > Compiler Error Message: BC30451: Name 'TestFunct' is not declared. >> > >> > Source Error: >> > >> > >> > Line 18: Sub Page_Load(s As Object, e As EventArgs) >> > Line 19: >> > Line 20: Dim result=TestFunct("This is a string") >> > Line 21: response.write("<BR>Result ==> " & Result) >> > Line 22: >> > >> > >> > I have a single .ASPX file and I don't use Visual studio. NET in this >> > case. >> > Can I do that ? >> > >> > Thanks in advance. >> > >> > >> >> > > |
|
||
|
||||
|
bienwell
Guest
Posts: n/a
|
Thanks, Tom. I did try it last time and it worked when I put all the files
in an application using Visual Studio.NET. My requirement now is to create a single .ASPX file containing VB.NET language, JavaScript language and HTML, and call a function from this .ASPX file without using Visual Studio.NET to create an application. .. "tom pester" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)... > Hi Kevin, > > This article is what you need when using asp.net 1.1 > > http://aspnet.4guysfromrolla.com/articles/122403-1.aspx > > It gest even simpler if you use asp.net v2. In this cas just drop the class > file in the App_Code directory and you can call them everywhere. > > Let me know if you have any more questions... > > Cheers, > Tom Pester > > > You're not thinking fourth-dimensionally! (- Back to the Future) > > > > Actually, you're not thinking Object-Orientationally. > > > > ASP.Net is object-oriented, and you'd better get acquainted with it, > > or you'll be visiting here almost daily, and writing crappy code until > > you do. Let me elaborate, if you will: > > > > Files are source code. Your application doesn't have files. It has > > classes. A file defines a class, but IS not a class. A class is a data > > type, and exists in the context of a running application. So, when > > you're talking about how your application works, the first thing you > > need to do is think about classes, not files. A file can contain one > > or MORE class definitions, and you need to get acquainted with classes > > to be successful with .Net. > > > > Classes are very important in .Net programming; Objects are made from > > classes, and classes provide encapsulation. Object-oriented > > programming can get pretty darned complex, and encapsulation can save > > you a lot of grief, by hiding those things which need hiding from > > those things that don't need them. > > > > If you have a file with a bunch of Subs and Functions in it, you need > > to create a class with Subs and Functions in it. These Subs and > > Functions can be Shared (meaning that they are singleton objects that > > don't require a class instance to operate), or they can be Instance > > (meaning that an instance of the class containing them must be created > > in order to use them). The advantage to Shared data and process is > > that it doesn't require a class instance, and is, in essence "global," > > available to the entire application. This is also the disadvantage of > > Shared data and process. Anything can get to it, and change it, and in > > a multi-threaded app (unlike VB 6, .net is multi-threaded), this can > > cause all sorts of problems. Unless you're familiar with the issues, I > > would stick with classes that require instantiation. Instantiation is > > the process of creating a copy (instance) of a class that is limited > > in its scope (availability), and is thread-safe. > > > > Once you create an instance of a class, you can access any Public or > > Friend (Friend is more protected than Public, but you shouldn't run > > into issues right away) members from any other class that references > > the instance. > > > > From your question, and the code you posted, I can see that you > > require a good bit more education and practice. I would recommend the > > .Net SDK, a free download from: > > > > http://www.microsoft.com/downloads/d...=9B3A2CA6-3647 > > -4070-9F41-A333C6B9181D&displaylang=en > > > > It is extremely important to know the difference between ASP and > > ASP.Net, between VBScript or VB 6, and VB.Net. The first are > > procedural, single-threaded, and easy to use for small applications. > > .Net is object-oriented, multi-threaded, and easy to use once you > > spend a great deal of time studying it, but incredibly hard to use if > > you don't. > > > > Kevin Spencer > > Microsoft MVP > > .Net Developer > > Everybody picks their nose, > > But some people are better at hiding it. > > "bienwell" <(E-Mail Removed)> wrote in message > > news:(E-Mail Removed)... > > > >> 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 strInput As String) > >> return (strInput & " test") > >> End Sub > >> I'd like to call this function in FileFunct.vb from another .ASPX > >> file like this : > >> > >> <%@ import Namespace="System" %> > >> <%@ import Namespace="System.Data" %> > >> <html> > >> <head> > >> <title>Test page</title> > >> </head> > >> <body> > >> <script runat="server" language="VB" scr="FileFunct.vb" > > >> Sub Page_Load(s As Object, e As EventArgs) > >> Dim result=TestFunct("This is a string") > >> response.write("<BR>result ==> " & result) > >> End Sub > >> </script> > >> </body> > >> </html> > >> I've got this error: > >> > >> Server Error in '/' Application. > >> --------------------------------------------------------------------- > >> ------- ---- > >> > >> Compilation Error > >> Description: An error occurred during the compilation of a resource > >> required > >> to service this request. Please review the following specific error > >> details > >> and modify your source code appropriately. > >> Compiler Error Message: BC30451: Name 'TestFunct' is not declared. > >> > >> Source Error: > >> > >> Line 18: Sub Page_Load(s As Object, e As EventArgs) > >> Line 19: > >> Line 20: Dim result=TestFunct("This is a string") > >> Line 21: response.write("<BR>Result ==> " & Result) > >> Line 22: > >> I have a single .ASPX file and I don't use Visual studio. NET in this > >> case. > >> Can I do that ? > >> Thanks in advance. > >> > > |
|
||
|
||||
|
tom pester
Guest
Posts: n/a
|
If you use asp.net version 1 you need to compile the class file with the command line compiler and put the created dll in the bin directory. Check out this 2 part article : http://www.4guysfromrolla.com/webtech/112101-1.2.shtml If you use asp.net version 2 just drop the class files in the App_Code and that's it. The engine will compile all files in this dir and make it available to the whole app without us to worry about compilation Let me know if it helped you or not... Cheers, Tom Pester > Thanks, Tom. I did try it last time and it worked when I put all the > files in an application using Visual Studio.NET. My requirement now > is to create a single .ASPX file containing VB.NET language, > JavaScript language and HTML, and call a function from this .ASPX > file without using Visual Studio.NET to create an application. > > . > "tom pester" <(E-Mail Removed)> wrote in message > news:(E-Mail Removed)... >> Hi Kevin, >> >> This article is what you need when using asp.net 1.1 >> >> http://aspnet.4guysfromrolla.com/articles/122403-1.aspx >> >> It gest even simpler if you use asp.net v2. In this cas just drop the >> > class > >> file in the App_Code directory and you can call them everywhere. >> >> Let me know if you have any more questions... >> >> Cheers, >> Tom Pester >>> You're not thinking fourth-dimensionally! (- Back to the Future) >>> >>> Actually, you're not thinking Object-Orientationally. >>> >>> ASP.Net is object-oriented, and you'd better get acquainted with it, >>> or you'll be visiting here almost daily, and writing crappy code >>> until you do. Let me elaborate, if you will: >>> >>> Files are source code. Your application doesn't have files. It has >>> classes. A file defines a class, but IS not a class. A class is a >>> data type, and exists in the context of a running application. So, >>> when you're talking about how your application works, the first >>> thing you need to do is think about classes, not files. A file can >>> contain one or MORE class definitions, and you need to get >>> acquainted with classes to be successful with .Net. >>> >>> Classes are very important in .Net programming; Objects are made >>> from classes, and classes provide encapsulation. Object-oriented >>> programming can get pretty darned complex, and encapsulation can >>> save you a lot of grief, by hiding those things which need hiding >>> from those things that don't need them. >>> >>> If you have a file with a bunch of Subs and Functions in it, you >>> need to create a class with Subs and Functions in it. These Subs and >>> Functions can be Shared (meaning that they are singleton objects >>> that don't require a class instance to operate), or they can be >>> Instance (meaning that an instance of the class containing them must >>> be created in order to use them). The advantage to Shared data and >>> process is that it doesn't require a class instance, and is, in >>> essence "global," available to the entire application. This is also >>> the disadvantage of Shared data and process. Anything can get to it, >>> and change it, and in a multi-threaded app (unlike VB 6, .net is >>> multi-threaded), this can cause all sorts of problems. Unless you're >>> familiar with the issues, I would stick with classes that require >>> instantiation. Instantiation is the process of creating a copy >>> (instance) of a class that is limited in its scope (availability), >>> and is thread-safe. >>> >>> Once you create an instance of a class, you can access any Public or >>> Friend (Friend is more protected than Public, but you shouldn't run >>> into issues right away) members from any other class that references >>> the instance. >>> >>> From your question, and the code you posted, I can see that you >>> require a good bit more education and practice. I would recommend >>> the .Net SDK, a free download from: >>> >>> http://www.microsoft.com/downloads/d...Id=9B3A2CA6-36 >>> 47 -4070-9F41-A333C6B9181D&displaylang=en >>> >>> It is extremely important to know the difference between ASP and >>> ASP.Net, between VBScript or VB 6, and VB.Net. The first are >>> procedural, single-threaded, and easy to use for small applications. >>> .Net is object-oriented, multi-threaded, and easy to use once you >>> spend a great deal of time studying it, but incredibly hard to use >>> if you don't. >>> >>> Kevin Spencer >>> Microsoft MVP >>> .Net Developer >>> Everybody picks their nose, >>> But some people are better at hiding it. >>> "bienwell" <(E-Mail Removed)> wrote in message >>> news:(E-Mail Removed)... >>>> 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 strInput As String) >>>> return (strInput & " test") >>>> End Sub >>>> I'd like to call this function in FileFunct.vb from another .ASPX >>>> file like this : >>>> <%@ import Namespace="System" %> >>>> <%@ import Namespace="System.Data" %> >>>> <html> >>>> <head> >>>> <title>Test page</title> >>>> </head> >>>> <body> >>>> <script runat="server" language="VB" scr="FileFunct.vb" > >>>> Sub Page_Load(s As Object, e As EventArgs) >>>> Dim result=TestFunct("This is a string") >>>> response.write("<BR>result ==> " & result) >>>> End Sub >>>> </script> >>>> </body> >>>> </html> >>>> I've got this error: >>>> Server Error in '/' Application. >>>> ------------------------------------------------------------------- >>>> -- ------- ---- >>>> >>>> Compilation Error >>>> Description: An error occurred during the compilation of a resource >>>> required >>>> to service this request. Please review the following specific error >>>> details >>>> and modify your source code appropriately. >>>> Compiler Error Message: BC30451: Name 'TestFunct' is not declared. >>>> Source Error: >>>> >>>> Line 18: Sub Page_Load(s As Object, e As EventArgs) >>>> Line 19: >>>> Line 20: Dim result=TestFunct("This is a string") >>>> Line 21: response.write("<BR>Result ==> " & Result) >>>> Line 22: >>>> I have a single .ASPX file and I don't use Visual studio. NET in >>>> this >>>> case. >>>> Can I do that ? >>>> Thanks in advance. |
|
||
|
||||
|
|
|
| |
![]() |
| Thread Tools | |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Call Function from aspx | Miro | Microsoft ASP .NET | 17 | 21st Apr 2010 09:13 AM |
| aspx file call codebehind function | Raymond Chiu | Microsoft C# .NET | 7 | 9th Jan 2009 02:50 PM |
| How to call function from one aspx page from another | Jonathan | Microsoft ASP .NET | 8 | 11th Mar 2008 05:47 AM |
| Passing arguments to call a javscript function from aspx.cs file | moni | Microsoft C# .NET | 5 | 11th Apr 2007 10:17 PM |
| how to call a function in another aspx page? | Matthew Louden | Microsoft ASP .NET | 2 | 20th Nov 2003 08:56 PM |
Powered by vBulletin®. Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2010, Crawlability, Inc. |





