web是自己定义了一个控件,编译没有问题,但是运行的时候在page_load后提示未将对象引用设置到对象的实例。哪位能帮忙解释一下问题的所在,在线等待!

解决方案 »

  1.   

    html部分:
    <%@ Register TagPrefix="customwebcontrols" Namespace="CustomMapControl" Assembly="CustomMapControl" %>//自定义的控件注册
    <%@ Register TagPrefix="mapinfowebuiwebcontrols" Namespace="MapInfo.Web.UI.WebControls" Assembly="MapInfo.Web" %>
    <%@ Register TagPrefix="mapinfowebuiwebcontrols1" Namespace="MapInfo.Web.UI.WebControls" Assembly="MapInfo.Web, Version=1.0.0.75, Culture=neutral, PublicKeyToken=1687fa7c79f74305" %>
    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="CustomMapControl.WebForm1" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML xmlns:v="urn:schemas-microsoft-com:vml">
    <HEAD>
    <title>WebForm1</title>
    <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    <meta content="C#" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    <style>v\:* {
    BEHAVIOR: url(#default#VML)
    }
    </style>
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <mapinfowebuiwebcontrols:mapcontrol id="MapControl1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 40px"
    runat="server" WorkspaceFileName="WebForm1MapControl1.mws" Width="656px" Height="376px" BorderStyle="Solid" BorderWidth="1px"
    MapAlias="Map1" UseDesigntimeWorkspace="True" Format="Gif"></mapinfowebuiwebcontrols:mapcontrol><mapinfowebuiwebcontrols:toolbarcontrol id="ToolbarControl1" style="Z-INDEX: 102; LEFT: 32px; POSITION: absolute; TOP: 8px"
    runat="server" Width="224px" MapID="MapControl1">
    <mapinfowebuiwebcontrols:ZoomInToolControl id="ZoomInToolControl1" runat="server" MapID="MapControl1"></mapinfowebuiwebcontrols:ZoomInToolControl>
    <mapinfowebuiwebcontrols:ZoomOutToolControl id="ZoomOutToolControl1" runat="server" MapID="MapControl1"></mapinfowebuiwebcontrols:ZoomOutToolControl>
    <mapinfowebuiwebcontrols:PanToolControl id="PanToolControl1" runat="server" MapID="MapControl1"></mapinfowebuiwebcontrols:PanToolControl>
    <mapinfowebuiwebcontrols:DistanceToolControl id="DistanceToolControl1" runat="server" MapID="MapControl1" DistanceType="0"></mapinfowebuiwebcontrols:DistanceToolControl>
    <mapinfowebuiwebcontrols:CenterToolControl id="CenterToolControl1" runat="server" MapID="MapControl1"></mapinfowebuiwebcontrols:CenterToolControl>
    <customwebcontrols:rectangletoolcontrol id="c21" runat="server" MapID="MapControl1"></customwebcontrols:rectangletoolcontrol>//自定义的控件
    </mapinfowebuiwebcontrols:toolbarcontrol><asp:textbox id="TextBox1" style="Z-INDEX: 103; LEFT: 296px; POSITION: absolute; TOP: 8px" runat="server"
    Width="257px" Height="18px"></asp:textbox><MAPINFOWEBUIWEBCONTROLS1:RECTANGLESELECTIONTOOLCONTROL id="RectangleSelectionToolControl1" style="Z-INDEX: 104; LEFT: 616px; POSITION: absolute; TOP: 16px"
    runat="server" Width="40" Height="16" MapID="MapControl1"></MAPINFOWEBUIWEBCONTROLS1:RECTANGLESELECTIONTOOLCONTROL></form>
    </body>
    </HTML>
    代码部分:
    public class WebForm1 : System.Web.UI.Page
    {
    protected MapInfo.Web.UI.WebControls.MapControl MapControl1;
    protected MapInfo.Web.UI.WebControls.ZoomInToolControl ZoomInToolControl1;
    protected MapInfo.Web.UI.WebControls.ZoomOutToolControl ZoomOutToolControl1;
    protected MapInfo.Web.UI.WebControls.PanToolControl PanToolControl1;
    protected MapInfo.Web.UI.WebControls.CenterToolControl CenterToolControl1;
    protected MapInfo.Web.UI.WebControls.DistanceToolControl DistanceToolControl1;
    protected System.Web.UI.WebControls.TextBox TextBox1;
    protected CustomMapControl.RectangleToolControl c21;
    protected MapInfo.Web.UI.WebControls.RectangleSelectionToolControl RectangleSelectionToolControl1;
    protected MapInfo.Web.UI.WebControls.ToolbarControl ToolbarControl1;

    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    this.c21.rectoolhandler +=new CustomMapControl.RectangleToolControl.RectangleToolEventHandler(tf_MapToolAction);
    }
    执行完page_load后提示的错误