ASP.Net/Development/App Code Folder — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 18:30, 26 мая 2010
Содержание
Define your class in App_Code folder (C#)
<A href="http://www.nfex.ru/Code/ASPDownload/CustomClassInApp_CodeCS.zip">CustomClassInApp_CodeCS.zip( 1 k)</a>
1. <A href="/Code/ASP/Development/UsingAppCodeFolderC.htm">Using App_Code Folder (C#)</a> <A href="/Code/ASP/Development/UsingAppCodeFolderC.htm"></a> 2. <A href="/Code/ASP/Development/UsingAppCodeFolderVB.htm">Using App_Code Folder (VB)</a> <A href="/Code/ASP/Development/UsingAppCodeFolderVB.htm"></a> 3. <A href="/Code/ASP/Development/DefineyourclassinAppCodefolderVB.htm">Define your class in App_Code folder (VB)</a> <A href="/Code/ASP/Development/DefineyourclassinAppCodefolderVB.htm"></a>
Define your class in App_Code folder (VB)
<A href="http://www.nfex.ru/Code/ASPDownload/CustomClassApp_CodeVB.zip">CustomClassApp_CodeVB.zip( 1 k)</a>
1. <A href="/Code/ASP/Development/UsingAppCodeFolderC.htm">Using App_Code Folder (C#)</a> <A href="/Code/ASP/Development/UsingAppCodeFolderC.htm"></a> 2. <A href="/Code/ASP/Development/UsingAppCodeFolderVB.htm">Using App_Code Folder (VB)</a> <A href="/Code/ASP/Development/UsingAppCodeFolderVB.htm"></a> 3. <A href="/Code/ASP/Development/DefineyourclassinAppCodefolderC.htm">Define your class in App_Code folder (C#)</a> <A href="/Code/ASP/Development/DefineyourclassinAppCodefolderC.htm"></a>
Using App_Code Folder (C#)
<source lang="csharp">
File: Default.aspx <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server">
protected void Page_Load(object sender, System.EventArgs e) { Calculator myCalc = new Calculator(); Label1.Text = myCalc.Add(12, 12).ToString(); }
</script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">
<title>Untitled Page</title>
</head> <body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server"></asp:Label>
</form>
</body> </html> File: Calculator.cs using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public class Calculator {
public int Add(int a, int b) { return (a + b); } public int Subtract(int a, int b) { return (a - b); }
}
</source>
<A href="http://www.nfex.ru/Code/ASPDownload/UsingAppCodeFolder.zip">UsingAppCodeFolder.zip( 1 k)</a>
Using App_Code Folder (VB)
<source lang="csharp">
File: Default.aspx <%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Dim myCalc As New Calculator Label1.Text = myCalc.Add(12, 12) End Sub
</script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">
<title>Untitled Page</title>
</head> <body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server"></asp:Label>
</form>
</body> </html>
File: Calculator.vb Imports Microsoft.VisualBasic Public Class Calculator
Public Function Add(ByVal a As Integer, ByVal b As Integer) As Integer Return (a + b) End Function Public Function Subtract(ByVal a As Integer, ByVal b As Integer) As Integer Return (a - b) End Function
End Class
</source>
<A href="http://www.nfex.ru/Code/ASPDownload/UsingAppCodeFolderVB.zip">UsingAppCodeFolderVB.zip( 1 k)</a>