Dynamic Div creation asp.net

I am trying to create Div dynamically on the press of button click. For that i refered this link>> http://forums.asp.net/t/1349244.aspx and made code on server side(.cs page) as follows>> public static int i = 0; protected void Button1_Click(object sender, EventArgs e) { i++; HtmlGenericControl newControl = new HtmlGenericControl("div"); newControl.ID = "NEWControl"+i; newControl.InnerHtml = "This is a dynamically created HTML server control."; PlaceHolder1.Controls.Add(newControl); } This code was giving me just one div each time when i press the button., I wanted to have addition of divs. On client side using javascript also i tried>>
Both of these didnt work. What mistake am i making? Is there any thing wrong?
check your page Is it getting refreshed each time?

以上就是Dynamic Div creation asp.net的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准