我正在将现有的网站项目转换为Web应用程序,因为我已经创建了一个新的Web应用程序,并将网站项目的整个源代码复制到Web应用程序项目中。但是现在的问题是,当我编译项目时,.aspx.cs页中无法访问.aspx页控件。我正在使用目标框架3.5在VS 2012中执行此操作。
这是代码片段
HTML来源
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="View_Deal_Rights.aspx.cs" Inherits="Modules_View_Deal_Rights"
EnableEventValidation="false" ValidateRequest="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>
<%=ConfigurationManager.AppSettings["SystemName"]%></title>
</head>
<body leftmargin="0" topmargin="10" marginwidth="0" marginheight="0" rightmargin="0"
bottommargin="0">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="0">
</asp:ScriptManager>
<asp:Label ID="lblok" runat="server"></asp:Label>
<asp:Button ID="btnSave" runat="server" CssClass="button" Text="Save Deal" ValidationGroup="LastSave"/>
</form>
</body>
</html>
源代码背后
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using UTOFrameWork.FrameworkClasses;
using System.Collections;
using System.Data;
using System.Web.UI.HtmlControls;
using System.Text;
public partial class Modules_View_Deal_Rights : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
btnSave. // Here Button save is not accessable
lblok. // Here lblok is not accessable
}
}
}
在将应用程序从网站转换为Web应用程序时,需要将CodeFile更改为CodeBehind。
CodeBehind="View_Deal_Rights.aspx.cs"
一旦更改,然后进行构建,便可以访问。
有关更多详细信息,请参见以下问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句