如何在ascx中从ascx获取所有html元素?

时间:2016-06-15 01:34:31

标签: c# asp.net ascx

html代码由我的ascx.cs page_load事件部分自动生成。

然后,我想获取直接html元素的值来保存。那我该怎么办

此。 html代码没有属性(runat)。

这是关于我的Html代码生成的示例。

function genWorkOpinion(UserId) {
    var col;
    var tta;
    var Label;
    var now = new Date();
    var id = now.getHours().toString() + now.getMinutes() + now.getSeconds() + now.getMilliseconds();

    var bossCount = 0;

    col = window.jQuery("<div class='col-md-12'>");
    Label = window.jQuery("<Label>").text("SomeText");
    tta = window.jQuery("<textarea id='" + id + "'>").attr("style", "width:100%; height:100px");
    col.append(Label);
    col.append(tta);
    window.jQuery("#workOpinion").append(col);
}

1 个答案:

答案 0 :(得分:0)

您应该为输入标记或任何html元素添加name属性,例如:

<input type="text" id="name" name="name"/>

然后你可以用代码behinde得到它:

 if (IsPostBack)
 {
   nameBox = Request.Form["name"];
   Response.Write("Name: " + nameBox);
 }
相关问题