2009年4月21日 星期二

ASPNET C#-呼叫副程式

Default3.aspx.cs 程式碼如下
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
e myCSharpObject = new e();//建立新物件
Label1.Text = myCSharpObject.t(); //呼叫物件
}

}
------------------------------------------------------------------------
App_Code/Class1.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 e
{
public string t()
{
return "呼叫副程式成功!";//在此加入建構函式的程式碼
}
}

沒有留言:

張貼留言