Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/402.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# 获取为javascript动态创建的dropdownlist的客户端id_C#_Javascript_Asp.net_Drop Down Menu - Fatal编程技术网

C# 获取为javascript动态创建的dropdownlist的客户端id

C# 获取为javascript动态创建的dropdownlist的客户端id,c#,javascript,asp.net,drop-down-menu,C#,Javascript,Asp.net,Drop Down Menu,我已经在aspx/c#中创建了一个页面,它需要在下一页生成动态dropdownlist的输入。dropdownlist通过代码隐藏多次创建,具体取决于上一页中的输入。请建议我如何获取将在下一页生成的dropdownlist的clientID //这是新页面的功能。如何获取ddlTimeOfDeath dropdownlist的客户端Id var tbl2 = new Table(); tbl2.ID = "tbl2"; tbl2.BorderWidth = 1;

我已经在aspx/c#中创建了一个页面,它需要在下一页生成动态dropdownlist的输入。dropdownlist通过代码隐藏多次创建,具体取决于上一页中的输入。请建议我如何获取将在下一页生成的dropdownlist的clientID

//这是新页面的功能。如何获取ddlTimeOfDeath dropdownlist的客户端Id

var tbl2 = new Table();
        tbl2.ID = "tbl2";
        tbl2.BorderWidth = 1;
        tbl2.Attributes.Add("Width", "100%");
        tbl2.Attributes.Add("CssClass", "tbl");
        tbl2.Attributes.Add("rules", "all");

        TableRow row1 = new TableRow();
        TableCell cell00 = new TableCell();
        TableCell cell11 = new TableCell();
        TableCell cell22 = new TableCell();
        TableCell cell33 = new TableCell();
        TableCell cell44 = new TableCell();
        TableCell cell55 = new TableCell();
        TableCell cell66 = new TableCell();


        cell00.Text = "Sl No."; cell00.Attributes.Add("Width", "2%");
        cell00.Attributes.Add("class", "tblTDText"); cell00.Attributes.Add("align", "center"); row1.Cells.Add(cell00);

        cell11.Text = "Activity Name"; cell11.Attributes.Add("Width", "8%"); 
        cell11.Attributes.Add("Width", "20%"); cell11.Attributes.Add("class", "tblTDText"); row1.Cells.Add(cell11);

        cell22.Text = "Name of woman"; cell22.Attributes.Add("Width", "15%");
        cell22.Attributes.Add("class", "tblTDText"); cell22.Attributes.Add("align", "center"); row1.Cells.Add(cell22);

        cell33.Text = "Address of woman"; cell33.Attributes.Add("Width", "15%");
        cell33.Attributes.Add("class", "tblTDText"); cell33.Attributes.Add("align", "center"); row1.Cells.Add(cell33);

        cell44.Text = "Place of Death"; cell44.Attributes.Add("Width", "10%"); 
        cell44.Attributes.Add("class", "tblTDText"); cell44.Attributes.Add("align", "center"); row1.Cells.Add(cell44);

        cell55.Text = "Time of Death"; cell55.Attributes.Add("Width", "10%"); 
        cell55.Attributes.Add("class", "tblTDText"); cell55.Attributes.Add("align", "center"); row1.Cells.Add(cell55);

        cell66.Text = "Cause of Death"; cell66.Attributes.Add("Width", "5%"); 
        cell66.Attributes.Add("class", "tblTDText"); cell66.Attributes.Add("align", "center"); row1.Cells.Add(cell66);

        tbl2.Rows.Add(row1);
        for (int i = 0; i < actID.GetLength(0); i++)
        {
            string actId = actID[i, 0];
            if (actId != null)
            {
                actId=actId.Trim();
                if (actId == "12" || actId == "39" )
                {
                    _objclstT389._i64T389001 = actId;
                    _objclstT389.fn_getRecordPr(_errMsg);
                    string actName = _objclstT389._strT389002;
                    int dcount = Convert.ToInt32(actID[i, 1]);

                    for (int j = 0; j < dcount; j++)
                    {
                        TableRow row = new TableRow();
                        TableCell cell0 = new TableCell();
                        TableCell cell1 = new TableCell();
                        TableCell cell2 = new TableCell();
                        TableCell cell3 = new TableCell();
                        TableCell cell4 = new TableCell();
                        TableCell cell5 = new TableCell();
                        TableCell cell6 = new TableCell();


                        //cell1.Text = actID[i, 0] + "/" + actName;
                        if (j == 0)
                        {
                            cell0.Text = Convert.ToString(i + 1);
                            cell0.RowSpan = dcount;
                            cell0.Attributes.Add("align", "center");
                            row.Cells.Add(cell0);

                            cell1.Text = actName;
                            cell1.Attributes.Add("valign", "top");
                            cell1.RowSpan = dcount;
                            row.Cells.Add(cell1);
                        }
                        cell2.Attributes.Add("valign", "top");
                        TextBox tb1 = new TextBox();
                        tb1.ID="txtNameOFWman"+j;
                        tb1.Attributes.Add("runat", "server");
                        cell2.Controls.Add(tb1);
                        cell2.Attributes.Add("align", "center");
                        row.Cells.Add(cell2); 

                        cell3.Attributes.Add("valign", "top");
                        TextBox tb2 = new TextBox();
                        tb2.ID="txtAddrsOfWman"+j;
                        tb2.TextMode = TextBoxMode.MultiLine;
                        tb2.Attributes.Add("runat", "server");
                        cell3.Controls.Add(tb2);
                        cell3.Attributes.Add("align", "center");
                        row.Cells.Add(cell3);

                        cell4.Attributes.Add("valign", "top");
                        DropDownList ddl1 = new DropDownList();
                        ddl1.ID = "ddlPlaceOfDeath" + j;
                        ddl1.Attributes.Add("runat", "server");
                        ddl1.Items.Add(new ListItem("Select", "-1"));
                        ddl1.Items.Add(new ListItem("Hospital","1"));
                        ddl1.Items.Add(new ListItem("Home","2" ));
                        cell4.Controls.Add(ddl1);
                        cell4.Attributes.Add("align", "center");
                        row.Cells.Add(cell4); 

                        cell5.Attributes.Add("valign", "top"); cell5.Attributes.Add("align", "middle"); 
                        DropDownList ddlTimeOfDeath = new DropDownList();
                        ddlTimeOfDeath.ID = "ddlTimeOfDeath" + j;
                        ddlTimeOfDeath.Attributes.Add("runat", "server");
                        ddlTimeOfDeath.Attributes.Add("onchange", "javascript:SelectedIndexChange('" + ddlTimeOfDeath.ClientID + "')");
                        ddlTimeOfDeath.Items.Add(new ListItem("Select", "-1"));
                        ddlTimeOfDeath.Items.Add(new ListItem("During Antenatal Period", "1"));
                        ddlTimeOfDeath.Items.Add(new ListItem("During delivery", "2"));
                        ddlTimeOfDeath.Items.Add(new ListItem("In postpartum report", "3"));
                        Literal ltlBrk1 = new Literal(); ltlBrk1.Text = "<br />";
                        TextBox txtDuration = new TextBox();
                        txtDuration.ID = "txtDuration" + j;
                        txtDuration.Attributes.Add("runat", "server");
                        txtDuration.Width = 40;
                        Label lblDuration = new Label();
                        lblDuration.ID = "lblDays" + j;
                        lblDuration.Attributes.Add("runat", "server");
                        lblDuration.Text = "Duration ";
                        TextBox txtNoOfDays = new TextBox();
                        txtNoOfDays.ID = "txtNoOfDays" + i;
                        txtNoOfDays.Attributes.Add("runat", "server");
                        txtNoOfDays.Width = 40;
                        Label lblNoOfDays = new Label();
                        lblNoOfDays.ID = "lblDays" + j;
                        lblNoOfDays.Attributes.Add("runat", "server");
                        lblNoOfDays.Text = "No. of days ";
                        cell5.Controls.Add(ddlTimeOfDeath);
                        cell5.Controls.Add(lblDuration);
                        cell5.Controls.Add(txtDuration); cell5.Controls.Add(ltlBrk1);
                        cell5.Controls.Add(lblNoOfDays);
                        cell5.Controls.Add(txtNoOfDays);
                        cell5.Attributes.Add("align", "center");
                        row.Cells.Add(cell5);

                        cell6.Attributes.Add("valign", "middle");
                        TextBox tb3 = new TextBox();
                        tb3.ID = "txtCauseOfDeath" + j;
                        tb3.Attributes.Add("runat", "server");
                        cell6.Controls.Add(tb3);
                        cell6.Attributes.Add("align", "center");
                        row.Cells.Add(cell6);

                        tbl2.Rows.Add(row);

                    }
                }
            }
        }
        phSecBActivity.Controls.Add(tbl2);
var tbl2=新表();
tbl2.ID=“tbl2”;
tbl2.BorderWidth=1;
tbl2.Attributes.Add(“宽度”、“100%”);
tbl2.Attributes.Add(“CssClass”、“tbl”);
tbl2.Attributes.Add(“规则”、“全部”);
TableRow row1=新建TableRow();
TableCell cell00=新的TableCell();
TableCell cell11=新的TableCell();
TableCell cell22=新的TableCell();
TableCell cell33=新的TableCell();
TableCell cell44=新的TableCell();
TableCell cell55=新的TableCell();
TableCell cell66=新的TableCell();
cell00.Text=“Sl编号”;cell00.Attributes.Add(“宽度”、“2%”);
cell00.Attributes.Add(“class”,“tblTDText”);cell00.属性。添加(“对齐”、“居中”);第1行。单元格。添加(单元格00);
cell11.Text=“活动名称”;单元格11.属性。添加(“宽度”、“8%”);
单元格11.属性。添加(“宽度”、“20%”);cell11.Attributes.Add(“class”,“tblTDText”);第1行。单元格。添加(单元格11);
cell22.Text=“女性姓名”;单元格22.属性。添加(“宽度”、“15%”);
单元格22.Attributes.Add(“类”、“tblTDText”);单元格22.属性。添加(“对齐”、“居中”);第1行。单元格。添加(单元格22);
第33单元Text=“女性地址”;单元格33.属性。添加(“宽度”、“15%”);
单元格33.Attributes.Add(“class”,“tblTDText”);单元格33.属性。添加(“对齐”、“居中”);第1行。单元格。添加(单元格33);
第44单元Text=“死亡地点”;单元格44.属性。添加(“宽度”、“10%”);
cell44.Attributes.Add(“class”,“tblTDText”);单元格44.属性。添加(“对齐”、“居中”);第1行。单元格。添加(单元格44);
cell55.Text=“死亡时间”;单元格55.属性。添加(“宽度”、“10%”);
单元格55.Attributes.Add(“class”,“tblTDText”);单元格55.属性。添加(“对齐”、“居中”);第1行。单元格。添加(单元格55);
第66单元Text=“死亡原因”;单元格66.属性。添加(“宽度”、“5%”);
cell66.Attributes.Add(“class”,“tblTDText”);单元格66.属性。添加(“对齐”、“居中”);第1行。单元格。添加(单元格66);
tbl2.Rows.Add(第1行);
for(int i=0;i