代码之家  ›  专栏  ›  技术社区  ›  Ryan

简单复合控件-回发不工作

  •  2
  • Ryan  · 技术社区  · 14 年前

    我试图制作一个简单的复合控件-只是一个标签和文本框-但回发并没有被控件接收。

    我没有按照 this its not necessary - the TextBox control should tie in automagically .

    包含 文本框不用担心 回发,作为嵌入式控件 会用ASP.NET解决这个问题 自动。

    class TestControl : WebControl
    {
        Label _label;
        TextBox _textbox;       
    
        protected override void CreateChildControls()
        {
            _label = new Label();
            _label.Text = "Some Label ";
            Controls.Add(_label);
    
            _textbox = new TextBox();
            Controls.Add(_textbox);
    
            base.CreateChildControls();
        }
    

    编辑-我检查了Context.Request.Form.Items并验证表单数据是否恢复正常。我还直接在页面上放置了一个基本的文本框,效果很好。

    1 回复  |  直到 14 年前
        1
  •  2
  •   Brian Mains    14 年前

    请尝试从compositecontrol继承,这是专门用于此方案的基类。。谢谢。