Hello Jonathan,
We can put the code into a class, then call the code from code-behind of
the two pages.
Here is an example:
Suppose a function Add is needed in multiple pages' logic:
Function Add(byval a as integer, byval b as integer) as integer
Return a + b
End function
We can add a new class in the ASP.NET project by right clicking the
project, choose Add -> Class. Type the class name (e.g MyMath), and click
on OK. Visual studio will generate a MyMath.vb file in the App_code folder.
Then we put the Add code into the class.
If the code behind of both PageA.aspx and PageB.aspx need to call the
function, we can do it in this way:
Dim myMathObj as new MyMath
Dim result as integer = myMathObj.Add(1, 2)
If you have any other concerns or need anything else, please feel free to
let me know.
Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Aidy - 05 Mar 2008 09:28 GMT
Further to the above look into shared functions, esp if you don't need any
state stored between calls;
Shared Function Add(byval a as integer, byval b as integer) as integer
Return a + b
End function
Instead of;
Dim myMathObj as new MyMath
Dim result as integer = myMathObj.Add(1, 2)
you can use
Dim result as integer = MyMath.Add(1,2)
> Hello Jonathan,
>
[quoted text clipped - 30 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
Jonathan - 05 Mar 2008 19:12 GMT
I don't have Visual Studio -- I am just coding in FrontPage directly.
In your scenario, what would be the text content of MyMath.vb?
I am assuming that:
Dim myMathObj as new MyMath
would know to look in a file called MyMath.vb?
Also if I have mypage.aspx, what is the statement within the <% %> to call
a function from mypage.vb page?
If I was to write a .vb page in Notepad, what is the text head in there
needed before I start writing:
MyFunction()
End Function
TIA
> Hello Jonathan,
>
[quoted text clipped - 28 lines]
> =================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
Larry Bud - 05 Mar 2008 20:33 GMT
> I don't have Visual Studio -- I am just coding in FrontPage directly.
>
[quoted text clipped - 15 lines]
>
> End Function
I think it's folly to try to write asp.net code in anything but visual
studio. The Intellisense alone makes it a necessity. Note that there
is a free developer edition that you can download.
Jialiang Ge [MSFT] - 06 Mar 2008 03:18 GMT
Hello Jonathan,
As Larry said, a better tool to write ASP.NET code is Visual Studio. The
latest free edition is Visual Studio 2008 Express
http://www.microsoft.com/express/
You can download the Visual Web Developer 2008 for ASP.NET projects.
As for Frontpage, Frontpage also support "classes". We can new a text file
in Frontpage, rename the file to "MyMath.vb", then copy & paste the code
into it:
Public Class MyMath
Shared Function Add(ByVal a As Integer, ByVal b As Integer) As Integer
Return a + b
End Function
End Class
Then use the class in the codebehind of our aspx pages.
Hope it helps.
Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Jonathan - 06 Mar 2008 11:39 GMT
Thanks all of you for the information.
Will VS2008 interact correctly with my FP2K version? I have quite a lot of
pages on that FP site now.
Will it work on Windows 2000?
> Hello Jonathan,
>
[quoted text clipped - 24 lines]
> =================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
Jialiang Ge [MSFT] - 07 Mar 2008 02:23 GMT
Hello Jonathan,
Yes. Visual Studio 2008 can import Frontpage site in this way:
1. open Visual Studio 2008
2. File -> Open ->Web Site
3. In the Open Web Site dialog, choose File System in the left panel,
select the root directory of the frontpage site in the file system view.
and click on Open.
Visual Studio 2008 will work on Windows 2000.
Regards,
Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.
This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
Jialiang Ge [MSFT] - 11 Mar 2008 06:47 GMT
Hello Jonathan,
I am writing to check the status of the issue. Would you mind letting me
know the result of the suggestions? If you need further assistance, feel
free to let me know. I will be more than happy to be of assistance.
Have a great day!
Regards,
Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.
This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================