如果引用页面与用户控件在同一目录下没有问题,但是换了目录就有问题代码如下:
protected Pager oPage;

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
this.oPage.CategoryID=11;
this.oPage.PageSize=12;
this.oPage.CurrentPage=13;
this.oPage.RecordCount=10000;
this.oPage.PageCount=20;
this.oPage.BaseURL="Article_List.aspx";
this.oPage.isVisiblePageStyle1=true;
this.oPage.isVisiblePageStyle2=true;
this.oPage.isVisiblePageStyle3=true;
this.oPage.isVisiblePageStyle4=true;
this.oPage.PageStyle5_Param=8;//可选,默认为10,但必须赋值在this.oPage.isVisiblePageStyle5=true;之前
this.oPage.isVisiblePageStyle5=true; }运行后的错误如下
未将对象引用设置到对象的实例。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误: 
行 23:  {
行 24:  // 在此处放置用户代码以初始化页面
行 25:  this.oPage.CategoryID=11;
行 26:  this.oPage.PageSize=12;
行 27:  this.oPage.CurrentPage=13;
 源文件: d:\wwwroot\oyd\presentation\webform2.aspx.cs    行: 25 堆栈跟踪: 

解决方案 »

  1.   

    前端代码
    <%@ Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false" Inherits="EricCMS.Presentation.WebForm2" %>
    <%@ Register TagPrefix="uc1" TagName="Pager" Src="manage/Pager.ascx" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>WebForm2</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <uc1:Pager id="oPager" runat="server"></uc1:Pager>
    <asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 336px; POSITION: absolute; TOP: 96px" runat="server"
    Text="Button"></asp:Button>
    </form>
    </body>
    </HTML>我说的可有不清楚,可以加我的QQ,还请各位帮忙
      

  2.   

    http://community.csdn.net/Expert/topic/4235/4235847.xml?temp=8.907497E-03
    楼主同一问题问了两次???高人已经解答了.
      

  3.   

    adandelion(猪头)说的对!
    已经说好了!