clientbuildmanager.aspx.cs

来自「《圣殿祭司的ASP.NET 2.0开发详解——使用C#》光盘内容.包含了书籍所含」· CS 代码 · 共 49 行

CS
49
字号
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;
using System.Web.Compilation;

public partial class ClientBuildManager : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
	//预编译
	protected void btnCompiler_Click(object sender, EventArgs e)
	{
		/*您也可以这样写
		string vdir = "/MyDataSource";	//虚拟目录名称
		string srcLocation = "c:\\Inetpub\\wwwroot\\VS2005IDE";	//来源位置
		string tarLocation="c:\\Tmp\\VS2005IDE";	//目标位置

		System.Web.Compilation.ClientBuildManager cbm = new System.Web.Compilation.ClientBuildManager(vdir,srcLocation,tarLocation);
		cbm.PrecompileApplication();	//预编译
		 * */
		try
		{
			if (!(String.IsNullOrEmpty(txtVirtualDir.Text) && String.IsNullOrEmpty(txtSourceLocation.Text) && String.IsNullOrEmpty(txtTargetLocation.Text)))
			{
				System.Web.Compilation.ClientBuildManager cbm = new System.Web.Compilation.ClientBuildManager(txtVirtualDir.Text, txtSourceLocation.Text, txtTargetLocation.Text);
				cbm.PrecompileApplication();	//预编译
				txtMsg.Text = "预编译成功!";
			}
			else
			{
				txtMsg.Text = "TextBox不得为空白";
			}
		}
		catch(Exception ex)
		{
			txtMsg.Text = ex.ToString();
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?