C#读取/写入值到前台页面TextBox文本框

来源:互联网 发布:中衡设计怎么样 知乎 编辑:程序博客网 时间:2024/05/29 01:55

有时候做项目,那些字段多的页面很令人头疼,即耗费时间,精力。闲话少说,来看看取值方式

       
using System.Web.UI.HtmlControls;//引用命名空间
 
 private string getString() {            try            {                string text= "";                                                                                                                                                            TextBox text0;                TextBox text1;                TextBox text2;                Control control;                              for (int i = 0; i < this.htmltable.Controls.Count; i++)                {                    if (i > 1)                    {                                              control = this.caizhiTable.Controls[i];                        text0 = (TextBox)((HtmlTableCell)control.Controls[0]).Controls[1];                                              text1 = (TextBox)((HtmlTableCell)control.Controls[1]).Controls[1];                        text2 = (TextBox)((HtmlTableCell)control.Controls[2]).Controls[1];
text=text0.Text+text1.Text+text2.Text
                        //下面可以对文本框进行处理了          
                    }                }                return text;            }            catch (Exception excption) {                return "";            }                   }   
 
Html
<pre class="html" name="code">   <table  runat="server" id="htmltable"  >something..   </table


0 0
原创粉丝点击