【发布时间】:2013-05-20 13:52:14
【问题描述】:
我正在尝试使用字符串更新文本框。该字符串将被连接,然后将使用单击事件更新文本框。我可以在 windows 应用程序中执行此操作,但是当我尝试在 asp.net 应用程序中执行此操作时,我无法获得我想要的结果。
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.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 = string_punch + string_punch_Number_7;
txt_punch.Attributes.Add("Value", string_punch);
}
protected void btn_punch_8_Click(object sender, EventArgs e)
{
const string string_punch_Number_8 = "8";
string_punch = string_punch + string_punch_Number_8;
txt_punch.Attributes.Add("Value", string_punch);
}
我希望能够单击 btn_punch_7,然后单击 btn_punch_8,然后连接字符串,并使用两个数字更新文本框。每次单击按钮时,字符串都会设置为 null。感谢您提前提供帮助。
【问题讨论】:
标签: c# asp.net textbox concatenation string-concatenation