Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在C中获取属性的值_C#_Html_Asp.net_Textbox_Placeholder - Fatal编程技术网

C# 在C中获取属性的值

C# 在C中获取属性的值,c#,html,asp.net,textbox,placeholder,C#,Html,Asp.net,Textbox,Placeholder,我有几个文本框,动态添加占位符文本,稍后在我的代码中,我希望从每个文本框中检索该文本。下面是一个文本框示例: <asp:TextBox ID="tbFirstName" runat="server" CssClass="form-control" placeholder=""></asp:TextBox> 有什么建议吗?您可以通过属性名称来引用它 string firstname = tbFirstname.Attributes["placeholder"]; 或设置

我有几个文本框,动态添加占位符文本,稍后在我的代码中,我希望从每个文本框中检索该文本。下面是一个文本框示例:

<asp:TextBox ID="tbFirstName" runat="server" CssClass="form-control" placeholder=""></asp:TextBox>

有什么建议吗?

您可以通过属性名称来引用它

string firstname = tbFirstname.Attributes["placeholder"];
或设置占位符值

tbFirstName.Attributes["placeholder"]="Some text";

这对于HTML服务器控件也应该很好。

不客气。@Bauss,但MSDN没有提供任何示例该链接有一个示例??
tbFirstName.Attributes["placeholder"]="Some text";