访问stringbulder生成的html控件 [英] Access html control generated by stringbulder
本文介绍了访问stringbulder生成的html控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用字符串bulder添加了html控件并传递给div标签,如下所示
StringBuilder sbTest = new StringBuilder( string .Empty);
sbTest.Append( < input type ='text'runat = server name ='txtName'id ='txtId'/>);
dv.InnerHtml = sbTest.ToString();
现在我想在.cs文件后面的代码中访问该文本框。我怎么能访问那个?
解决方案
为什么要使用StringBuilder?为什么不呢:
dv.InnerHtml =< 输入 类型 = text runat = server 名称 = txtName id = txtId / > ;
StringBuilder在你的代码中完全没有意义。
此外,如果你只是添加一个textbo x到你的页面,你为什么不在我们的webform上拖动文本框?如果您希望文本框发布到代码隐藏,您可能只想将文本框添加到页面并使用css隐藏它。
Eduard
I have added html control using string bulder and pass to div tag like below
StringBuilder sbTest = new StringBuilder(string.Empty);
sbTest.Append("<input type='text' runat="server" name='txtName' id='txtId' />");
dv.InnerHtml = sbTest.ToString();
Now I want to access that textbox in code behind .cs file.How can I access that?
解决方案
Why do you use the StringBuilder?? Why not just :
dv.InnerHtml = "<input type="text" runat="server" name="txtName" id="txtId" />";
The StringBuilder makes no sense at all in your code.
Further more, if you just add a textbox to your page, why don't you just drag the textbox on our webform? If you want thetextbox to post to a code-behind, you may just want to always add the textbox to your page and hide it using css.
Eduard
这篇关于访问stringbulder生成的html控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文