JS:
1 function CreateNode() { 2 var div = document.getElementById('divMess'); 3 var Node = document.createElement("div"); //创建标签 4 Node.innerHTML = "你好 "; 5 Node.setAttribute("style", " 100%; float: left; height: 20px; line-height: 20px; text-align: center;"); 6 var text = document.createElement("input"); 7 text.setAttribute("type", "text"); 8 text.setAttribute("value", ""); 9 text.setAttribute("id", "txtMess"); 10 text.setAttribute("name", "mess"); 11 Node.appendChild(text); 12 div.appendChild(Node); 13 text.focus(); 14 }
CS:
1 Label lblshow; 2 private void CreateNewContorl(string mess) 3 { 4 lblshow = new Label(); 5 lblshow.Text = "<br />" + mess; 6 lblshow.Width = 150; 7 lblshow.Height = 100; 8 lblshow.CssClass = "Label"; 9 this.PanShowGJ.Controls.Add(lblshow); 10 }