有很多种可能,比如说在客户端你有一个控件,但是没加上runat=server,但是你已经在服务器端定义并使用了他的属性,就会报,还有需要实例化的对像没有实例化就用,也会产生,你还是把代码贴出来,标出出错行再来问吧

解决方案 »

  1.   

    思归,Continue!
    还是上次问题的继续,
    我已按你讲的改好了我的在线HTML编辑的模块,是ASCX的。已可以使用。
    我现在想把这个控件DLL化。
    我用的是自定义控件来DLL化这个东东。
    编译后,别的都通过,功能也正常,就是在ASPX文件里测试时,当点击提交按钮时,发生了上面的错误。
    为什么会出现这个错误?怎么解决?
    谢谢!
      

  2.   

    一般情况是,比如你用了一个类 Test;
    Test  mytest;
    你直接用mytest.Funtion();
    就会出现这种错误
    你应该先Test mytest = new Test();
    然后再使用.
      

  3.   


    namespace OrcasEdit
    {
    /// <summary>
    /// EditBox 的摘要说明。
    /// </summary>
    [DefaultProperty("HtmlText"), 
    ToolboxData("<{0}:EditBox runat=server></{0}:EditBox>")]
    public class EditBox : System.Web.UI.WebControls.WebControl
    {
    protected string _text;
    protected string _imagesiconfolder;
    protected string _cssfile;
    protected string _toolsfolder;
    protected System.Web.UI.HtmlControls.HtmlTextArea htext;

    public string HtmlText 
    {
    get
    {
    try
    {
    _text=System.Web.HttpUtility.HtmlDecode(this.htext.Value);
    }
    catch
    {throw;};
    return _text;
    }
      

  4.   

    错误是不是在System.Web.HttpUtility.HtmlDecode(this.htext.Value)中?
    htext是我在客户用的是个runat=server的textarea。
      

  5.   

    catch(Exception e)
    {
    throw;
    }
      

  6.   

    我用HtmlTextArea htext=new HtmlTextArea htext();
    解决报错。
    但是没有取到值!
    为什么?
    判断htext.Value==""成立。
    怎么取客户端的控件的值?