c# - 使用密码 TextMode 初始化 TextBox

标签 c# asp.net

我正在尝试在我的 C# 代码中使用密码 TextMode 初始化 TextBox。我在 Page_Load 函数中执行此操作。但是在浏览器中输出后没有文字。

this.passwordTextBox.Text = this.GetData().Password;
this.confirmPasswordTextBox.Text = this.GetData().Password;

如何为该属性赋值?

最佳答案

您可以使用以下方式设置密码:

this.passwordTextBox.Attributes["value"] = this.GetData().Password;

this.passwordTextBox.Attributes.Add("value", this.GetData().Password);

Setting the Value of a TextBox with TextMode=Password

关于c# - 使用密码 TextMode 初始化 TextBox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7709243/

相关文章:

c# - 在 LINQ 中采用所有三元运算符?

c# - 格式化导航栏颜色并在 Razor 中添加分隔线

c# - C# 中的字符串操作以递增数字

c# - Response.Redirect 失败但随后可以在刷新 IIS Express VS2013 上工作

c# - 在 div id 上使用 FindControl 时出错

javascript - 禁用 asp.net 按钮回发

c# - 检查数字数组是否连续的功能方法

c# - 我是否需要为 Windows Phone 8 和 Windows 8 桌面创建单独的应用程序?

javascript - SignalR 集线器 : JavaScript runtime error: Unable to get property 'multipleFileHub' of undefined or null reference

c# - 'System.IO.MemoryStream'不包含'for'定义吗?