简体   繁体   中英

How can i get all html element from ascx in ascx?

The html code is auto generate by my ascx.cs page_load event part.

Then, I want to get the directly html element's value to save. So How can i do

this. The html code is haven't the attribute(runat).

This is a example about my Html code generate.

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);
}

you should add a name attribute to your input tag or any html element, example:

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

then you can get it in code behinde as:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM