zoukankan      html  css  js  c++  java
  • ASP.NET中页面传递参数。

    第一页面用Server.Transfer跳转至第二页面。
    第二页面中核心代码如下:
    if(!Page.IsPostBack)
       {    
        Webtest1 _webtest1;
        _webtest1 = (Webtest1) Context.Handler;
        if(_webtest1!=null)
        {
         ViewState["TNum"] = System.Convert.ToInt32(((TextBox)_webtest1.FindControl("TextBox1")).Text.Trim());     
        }
       }
       table1.Controls.Clear();
       if(System.Convert.ToInt32(ViewState["TNum"].ToString())>0)
       {
        for(int i=0;i<System.Convert.ToInt32(ViewState["TNum"].ToString());i++)
        {
         HtmlTableRow tr = new HtmlTableRow();
         HtmlTableCell cell = new HtmlTableCell();
         TextBox newbox = new TextBox();
         newbox.Text = "第"+i.ToString()+"个";
         newbox.Width = 180;
         newbox.ID = "DynTextBox"+i.ToString();
         newbox.Attributes.Add("name", newbox.ID);
         //ViewState[newbox.ID] = newbox;
         cell.Controls.Add(newbox);
         tr.Controls.Add(cell);
         table1.Controls.Add(tr);
        }
       }
    //获取动态生成控件中的内容。
       string res ="";
       for (int i=0;i<System.Convert.ToInt32(ViewState["TNum"].ToString());i++)
       {
        //res = this.Controls[i].ID;
        //Control myControl1 = FindControl("DynTextBox"+i.ToString());
        TextBox txt0 = (TextBox)this.FindControl("DynTextBox"+i.ToString());
        res+= txt0.Text;    
       }
       Response.Write(res); 
  • 相关阅读:
    Flex 布局
    前端跨域之jsonp
    vs code 自定义代码片段
    vue中使用axios进行http通信
    Table边框合并
    getElementsBy 系列方法相比querySelector系列的区别
    vue中watch简单使用
    png图标任意赋色
    pc端与移动端适配解决方案之rem
    Express post请求无法解析参数的原因
  • 原文地址:https://www.cnblogs.com/joxin/p/77001.html
Copyright © 2011-2022 走看看