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

Home Posts Topics Members FAQ

Include file

JH
I'm new in the .NET world, so sorry if this is a faq. In classic ASP I
often use a include file with some standard functions, ex. formating a
string an so. How do a do this i .NET ??

In my test code below, I submit a form with a textbox, use the
function "format_string" to change the value. I would like to use this
function in other scripts also, so need to place the code in another
file, and include it, how ?

I'll appreciate if someone could change my test code, to show me the
right way to do it.

Thx..

test.aspx
------------------
<%@ page language="vb" inherits="test" src="test.vb" %>
<html>
<head>
</head>

<body>
<form id="test" method="post" runat="server">
<asp:textbox id="sometext" text="" runat="server" />
<asp:button id="submit" text="submit" onclick="test_me"
runat="server" />
</form>
</body>
</html>
------------------
test.vb
------------------
Imports System
Imports System.Web.UI

public class test : inherits page
sub test_me(ByVal Sender As Object, ByVal E As EventArgs)
dim sometext as string
sometext = format_string(Request.Form("sometext"))
end sub

function format_string(value as string) as string
return "!" & value & "!"
end function
end class
------------------

Nov 17 '05 #1
3 2487
Hi

Check out the following articles, which tells about How
to include files in aspx.

http://www.csharpfriends.com/Articles/getArticle.aspx?
articleID=9

http://www.aspalliance.com/stevesmit...es/includelets
..asp

Ravikanth

-----Original Message-----
I'm new in the .NET world, so sorry if this is a faq. In classic ASP Ioften use a include file with some standard functions, ex. formating astring an so. How do a do this i .NET ??

In my test code below, I submit a form with a textbox, use thefunction "format_string" to change the value. I would like to use thisfunction in other scripts also, so need to place the code in anotherfile, and include it, how ?

I'll appreciate if someone could change my test code, to show me theright way to do it.

Thx..

test.aspx
------------------
<%@ page language="vb" inherits="test" src="test.vb" %>
<html>
<head>
</head>

<body>
<form id="test" method="post" runat="server">
<asp:textbox id="sometext" text="" runat="server" />
<asp:button id="submit" text="submit" onclick="test_me"runat="server" />
</form>
</body>
</html>
------------------
test.vb
------------------
Imports System
Imports System.Web.UI

public class test : inherits page
sub test_me(ByVal Sender As Object, ByVal E As EventArgs) dim sometext as string
sometext = format_string(Request.Form("sometext"))
end sub

function format_string(value as string) as string
return "!" & value & "!"
end function
end class
------------------

.

Nov 17 '05 #2
The easiest way would be to make some utility classes.

public class StringUtilities
{
public static string FormatString(string s)
{
string result;

//Do something
return result;
}
}
And then in the code-behind you just use the class:

private void Page_Load(...)
{
string s="Hello 123";
s=StringUtilities.FormatString(s);
}

I hope this helps
Hugo
Nov 17 '05 #3
JH
> The easiest way would be to make some utility classes.

Thanks for your reply.... I like the idea with a "utility class".
I put this code in ex. "StringUtilities.vb", and place it in a shared
include-folder
-----
public class StringUtilities
{
public static string FormatString(string s)
{
string result;

//Do something
return result;
}
} -----

How do my codebehind code (test.vb) know about the class
"StringUtilities" ??
----- private void Page_Load(...)
{
string s="Hello 123";
s=StringUtilities.FormatString(s);
}

-----

Nov 17 '05 #4

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

Similar topics

7
by: mescaline | last post by:
Hi, Suppose a_file.cpp contains a function a_function() Now to include it in main_file.cpp I just do #include "a_file.cpp" and I'm all set. i recently came across this seemingly roundabout...
6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
28
by: Ramesh | last post by:
Hi, I am currently maintaining a legacy code with a very very large code base. I am facing problems with C/C++ files having a lot of un-necessary #includes. On an average every C/C++ file has...
60
by: Derrick Coetzee | last post by:
It seems like, in every C source file I've ever seen, there has been a very definite include order, as follows: - include system headers - include application headers - include the header...
9
by: bill | last post by:
Forget the exact definition of difference between, #include <foo.h> and #include "bar.h" Normally foo.h is a standard header file, so it's path is not defined in compiler option, but I...
12
by: Francois Grieu | last post by:
Can #include safely use a preprocessing token, as in #define HEADERFILE "stdio.h" #include HEADERFILE int main(void) {return printf("Hello, world\n")*0;} TIA, François Grieu
9
by: zolli | last post by:
Hi, I've been banging my head against this for a while now. Hoping someone here can shed some light on what's going on. On including stdlib.h in a file, I'm seeing the following errors: ...
5
by: David Mathog | last post by:
One thing that can make porting C code from one platform to another miserable is #include. In particular, the need to either place the path to an included file within the #include statement or to...
3
by: Arpi Jakab | last post by:
I have a main project that depends on projects A and B. The main project's additional include directories list is: ...\ProjectA\Dist\Include ...\ProjectB\Dist\Include Each of the include...
6
by: tshad | last post by:
In my User control, I tried to do this: *************************************************************************** <Script runat="server"> Public ClientName As String = "<!-- #include file =...
0
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
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
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,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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
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
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
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.