protected const string LINK_TEXTBOX = "<asp:textbox id=\"txtRe\"></asp:textbox>";
我用断点调试的时候,显示时有反斜扛!这个初始化应该怎样写

解决方案 »

  1.   

    protected const string LINK_TEXTBOX = "<asp:textboxid='txtRe'></asp:textbox>";writer.Write(LINK_TEXTBOX);
    并没有动态创建出一个文本框啊
      

  2.   

    writer.Write(LINK_TEXTBOX)只能输出html字符类似<asp:textboxid='txtRe'></asp:textbox>的标签输出到客户端,浏览器是解析不了的动态创建文本框使用Page.Controls.Add(new TextBox());而且每次回发的时候要重新创建,否则会丢失状态
      

  3.   

    如果是后台创建的话,应该先找个容器.比如<form id="form1" runat="server">然后就可以
    定义任何一个你想要的控件实例ctl
    接着form1.Controls.add(ctl)就OK
      

  4.   

    我是再一个表格里动态创建文本框控件!
    protected const string HTML1 = "<table width=96% border=0 cellpadding=0 cellspacing=0 align=center><tr><td colspan=2>";
    protected const string HTML2 = "</td></tr><tr class=gridNav><td>总数:{0} 总页数:{1} 当前页数:{2}";
    protected const string HTML3 = "</td><td align=right>";
    protected const string HTML4 = "</td></tr></table>";
    private const string LINK_PREV = "<a href=?page={0}>上一页</a>";
    private const string LINK_MORE = "<a href=?page={0}>下一页</a>";
    private const string LINK_FIRST = "<a href=?page={0}>第一页</a>";
    private const string LINK_LAST = "<a href=?page={0}>最后一页</a>";
    private const string LINK_TURN = "<a href=?page={0}>跳转</a>";writer.Write(HTML1);

    // Call the inherited method
    base.Render(writer); // Write out a table row closure
    //writer.Write(HTML2);
    writer.Write(string.Format(HTML2, _itemCount,PageCount+1,_currentPageIndex+1)); //Close the table data tag
    writer.Write(HTML3);  writer.Write(LINK_TEXTBOX);
                 //writer.Write(string.Format(LINK_TURN, 35 + query));

    //Determin whether next and previous buttons are required
    //Previous button?
    if (_currentPageIndex > 0)
    {

    writer.Write(string.Format(LINK_FIRST, 0 + query));
    writer.Write(string.Format(LINK_PREV, (_currentPageIndex - 1) + query));
    } //Next button
    if (_currentPageIndex < PageCount)
    {
    writer.Write(string.Format(LINK_MORE, (_currentPageIndex + 1) + query));
    writer.Write(string.Format(LINK_LAST, PageCount + query));
    } //Close the table
    writer.Write(HTML4);
    问题是怎么再跳转前面出现一个文本框,来实现页面的挑转