zoukankan      html  css  js  c++  java
  • 呈现控件时出错,未将对象的引用设置到对象的实例(未創建子控件。。。)

    ///
            /// 将此控件呈现给指定的输出参数。
            ///
            /// 要写出到的 HTML 编写器
            protected override void Render(HtmlTextWriter output)
            {

                如果沒有下面一句,則報錯!!!

                EnsureChildControls();
                output.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
                output.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
                if (DesignMode)
                {
                    output.AddAttribute(HtmlTextWriterAttribute.Style, "border:0px; border-collapse:collapse;");
                }
                output.RenderBeginTag(HtmlTextWriterTag.Table);

                output.RenderBeginTag(HtmlTextWriterTag.Tr);

                output.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "0px");
                output.RenderBeginTag(HtmlTextWriterTag.Td);
                _hiddenField.RenderControl(output);
                _textBoxCode.RenderControl(output);
                output.RenderEndTag();

                output.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "0px");
                output.RenderBeginTag(HtmlTextWriterTag.Td);
                output.AddAttribute(HtmlTextWriterAttribute.Style, "border:solid 1px #AECAF0; border-left:0px; border-right:0px; height:20px; line-height:20px;");
                output.AddAttribute(HtmlTextWriterAttribute.Type,"button");
                output.AddAttribute(HtmlTextWriterAttribute.Value,"選擇");
                output.AddAttribute(HtmlTextWriterAttribute.Onclick, "if(typeof(popupURL)!=\"undefined\"){popupURL.SetContentHTML('');popupURL.SetContentUrl('" + BaseDataUrl + "?t=" + BaseDataType + "&sid=" + FieldName + "&v='+(new Date()).getTime());popupURL.Show();}");
                output.RenderBeginTag(HtmlTextWriterTag.Input);
                output.RenderEndTag();
                output.RenderEndTag();

                output.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "0px");
                output.RenderBeginTag(HtmlTextWriterTag.Td);
                _textBoxName.RenderControl(output);
                output.RenderEndTag();

                output.RenderEndTag();

                output.RenderEndTag();
            }

  • 相关阅读:
    c# 第29节 类
    c# 第28节 面向对象概述
    c# 第27节 结构、枚举
    c# 第26节 Main方法
    c# 第25节 方法重载
    Python接口自动化之yaml配置文件
    Python接口自动化之数据驱动
    Python接口自动化之登录接口测试
    测试面试题集-逻辑推理题
    Python接口自动化之unittest单元测试
  • 原文地址:https://www.cnblogs.com/luoyaoquan/p/2029585.html
Copyright © 2011-2022 走看看