我在网页表单上放置了几个按钮,用户点击它们后将更新文本框。这个功能之前都能正常运行,但是当我添加textmode=password时就出现问题了。现在文本框不再显示文本。我调试了应用程序,发现text属性确实得到了值,但是仍然没有显示。
以下是我尝试过的方法:
protected void btn_punch_7_Click(object sender, EventArgs e)
{
const string string_punch_Number_7 = "7";
var text = txt_punch.Text;
text += string_punch_Number_7;
txt_punch.Text = text;
}
protected void btn_punch_8_Click(object sender, EventArgs e)
{
const string string_punch_Number_8 = "8";
var text = txt_punch.Text;
text += string_punch_Number_8;
txt_punch.Text = text;
}
我也尝试过这个:
public partial class WebForm3 : System.Web.UI.Page
{
public string string_punch;
protected void Page_Load(object sender, EventArgs e)
{
MultiView1.SetActiveView(View1);
txt_punch.Width = 300;
txt_punch.Height = 50;
txt_punch.MaxLength = 4;
txt_punch.Attributes.Add("OnChange", string_punch);
}
protected void btn_punch_7_Click(object sender, EventArgs e)
{
const string string_punch_Number_7 = "7";
string_punch = txt_punch.Text;
string_punch += string_punch_Number_7;
txt_punch.Text = string_punch;
}
protected void btn_punch_8_Click(object sender, EventArgs e)
{
const string string_punch_Number_8 = "8";
string_punch = txt_punch.Text;
string_punch += string_punch_Number_8;
txt_punch.Text = string_punch;
}