日期:2014-05-18  浏览次数:20768 次

前台页面直接条用后台程序出错
我后台有一个protect void 类型的GetData方法,前台条用时候提示上下文不存在名称
前台代码
<%@ Page Language="C#" MasterPageFile="~/MasterPage/FormPage.master" AutoEventWireup="true" CodeBehind="Finance.aspx.cs" Inherits="AdenWeb.Finance.FinancePage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentData" runat="server">
  <%GetData(); %>
</asp:Content>

后台代码
namespace AdenWeb.Finance
{
  public partial class FinancePage : WebForm
  {

  protected void GetData()
  {
  try
  {
  Response.Write("test");
  }
  catch (Exception e)
  {
   
  }
  }

  }


------解决方案--------------------
protected => public
------解决方案--------------------
public void GetData()
------解决方案--------------------
楼上正解!
------解决方案--------------------
一楼二楼正解,页面访问后台方法,必须是公共方法...
------解决方案--------------------
<%=GetData(); %>