[英]Get text from dynamically-generated textbox to insert with button
I am creating divs with textbox and a button on each one. 我正在创建带有文本框和每个按钮的div。 They are being created like this: 它们是这样创建的:
TextBox txtGosto = new TextBox();
txtGosto.ID = "txtGosto_" + postid;
Then, a button after it with an EventHandler to submit the text. 然后,在其后带有EventHandler的按钮提交文本。
btnInsertPost.ID = "btnInsertPost_" + postid;
btnInsertPost.Click += (sender, e) => { InsertPost(sender, e, postid); };
The postid is working and being passed as an argument, but i am wondering how can i get the text from the dynamic generated textbox and submit it too. 该postid正在运行并作为参数传递,但是我想知道如何从动态生成的文本框中获取文本并提交。
Think you might be after the txtGosto.Text property. 认为您可能在txtGosto.Text属性之后。
https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.text(v=vs.110).aspx https://msdn.microsoft.com/zh-cn/library/system.web.ui.webcontrols.textbox.text(v=vs.110).aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.