Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在C#asp.net中获取运行时创建的所有控件的值_C#_Asp.net - Fatal编程技术网

如何在C#asp.net中获取运行时创建的所有控件的值

如何在C#asp.net中获取运行时创建的所有控件的值,c#,asp.net,C#,Asp.net,//此函数用于创建id为fileid1、fileid2、fileid3等的多个htmlcontrol“content\u data”是一个html div id 受保护的无效输入\u记录\u btn\u单击(对象发送方,事件参数e) { 字符串控制_data=”“; 对于(Int64 x=1;x您正在Div中呈现一个字符串,而不是实际将控件添加到网页中,因此find控件将不起作用。您可能需要读取正在写入的Div的html才能获取控件 或者,向页面添加一个实际控件,以便能够使用findcontro

//此函数用于创建id为fileid1、fileid2、fileid3等的多个htmlcontrol“content\u data”是一个html div id

受保护的无效输入\u记录\u btn\u单击(对象发送方,事件参数e) {

字符串控制_data=”“;

对于(Int64 x=1;x您正在Div中呈现一个字符串,而不是实际将控件添加到网页中,因此find控件将不起作用。您可能需要读取正在写入的Div的html才能获取控件

或者,向页面添加一个实际控件,以便能够使用findcontrol

i、 e MyPannel.controls.add(新建ctrl

这里有一个很好的例子:)

为什么要使用
Int64
for your循环变量的上限为4?您添加的是字符串,而不是控件。
    String control_data="";
    for (Int64 x = 1; x <= 4; x++)
    {
        control_data = control_data + "<input type='text' id='fileid" + x + "' runat='server' /> ";
    }

    content_data.InnerHtml = control_data;
}
      for(Int64 i=1;i<=4;i++)
       {
        HtmlInputText text1,
        text1 = (System.Web.UI.HtmlControls.HtmlInputText)Page.FindControl("fileid" + i);
        Response.write(text1.value); 
       }