CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  ASP.NET

复合控件中动态生成DropDownList,其数据及选择的是那项是否要记下来下次CreateChildControls中使用便于恢复状态?

楼主luojizi(尘封)2003-02-02 12:05:46 在 .NET技术 / ASP.NET 提问

能自动恢复状态吗? 问题点数:0、回复次数:3Top

1 楼saucer(思归)回复于 2003-02-02 12:10:22 得分 0

yes,   if   you   make   sure   CreateChildControls   is   called   before   LoadViewState   occurs,   for   example,   in   Page_Init,   call  
  YourCompositeControlID.FindControl("Whatever");  
  Top

2 楼luojizi(尘封)回复于 2003-02-02 12:51:26 得分 0

很对不起,我不明白你的“yes”是回答  
  是能自动恢复状态  
  还是要记下状态用于下次重现?Top

3 楼saucer(思归)回复于 2003-02-02 14:07:09 得分 0

play   with  
   
  1.   MyComposite.cs:   (compile   it   into   MyComposite.dll   and   copy   it   to   the   bin   subdirectory)  
   
  using   System;  
  using   System.Web;  
  using   System.Web.UI;  
  using   System.Web.UI.WebControls;  
   
  namespace   MyCompositeNamespace   {  
   
          public   class   MyComposite   :   Control,   INamingContainer   {  
                 
                  protected   override   void   CreateChildControls()    
  {  
          DropDownList   ddl   =   new   DropDownList();  
          ddl.ID   =   "DropDownList1";  
          for   (int   i=1;   i   <=   10;   i++)  
  ddl.Items.Add(i.ToString());  
          this.Controls.Add(ddl);  
                  }  
          }  
  }  
   
  2.   MyComposite.aspx:  
  <%@   Register   TagPrefix="my"   Namespace="MyCompositeNamespace"   Assembly="MyComposite"   %>  
        <script   language="C#"   runat=server>  
              void   Page_Init(Object   sender,   EventArgs   e)    
              {  
  //to   make   sure   the   controls   inside   MyControl   are   created   first,   uncomment   the   following   line  
  //   MyControl.FindControl("whatever");  
              }  
        </script>  
  <html>  
        <body>  
              <form   runat=server>  
                      <my:MyComposite   id="MyControl"   runat="server"/>  
                      <br/>    
        <asp:button   id="Btn"   text="submit"   runat=server/>  
              </form>  
        </body>  
  </html>  
  Top

相关问题

  • web复合控件。
  • 再问:为什么在复合控件CreateChildControls()里创建的子控件对不齐?!!!
  • 复合控件和自定义控件
  • 复合控件的问题
  • 复合控件的属性!
  • 复合控件的属性
  • DropDownList控件问题
  • dropdownlist控件问题
  • DropDownList 和datagrid 控件
  • DropDownList控件问题?

关键词

  • createchildcontrols
  • mycomposite
  • dropdownlist
  • 下次
  • ddl
  • 能自动恢复状态
  • ui
  • yes
  • using system

得分解答快速导航

  • 帖主:luojizi

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo