由网友(北辰)分享简介:我有一个标准输入:我想有这种渲染一个充满活力的 HTML5占位符。是这样的:'Code BehindtxtSearchTerm.**placeholder** = "Search " + Si...
我有一个标准输入:
<asp:TextBox type="text" runat="server" id="txtSearchTerm" />
我想有这种渲染一个充满活力的 HTML5占位符。是这样的:
'Code Behind
txtSearchTerm.**placeholder** = "Search " + Site.Name
因此,它输出以下HTML:
So that it outputs the following HTML:
<input type="text" runat="server" id="txtSearchTerm"
placeholder="Search Site #1" />
在这里Site.Name =网站#1。
where Site.Name = "Site #1".
txtSearchTerm。占位符是不是一个属性。我有它设置为文本,然后运行JavaScript来显示对焦点/隐藏,而是我宁愿只使用HTML5占位符值。我怎样才能使这个?
txtSearchTerm.placeholder is not a property. I have it set to text and then run javascript to show/hide on focus BUT I would much rather just use the HTML5 placeholder value. How can I render this?
请没有JS /客户端的解决方案。
Please no JS/client side solutions.
推荐答案
您可以使用属性
集合。所以,你会碰到这样的
You could use the Attributes
collection. So you would have something like
txtSearchTerm.Attributes.Add("placeholder", "Search" + Site.Name);
或
txtSearchTerm.Attributes["placeholder"] = "Search" + Site.Name; // or Attributes("placeholder") if you're using vb.net
相关推荐
最新文章