本文介绍了如何在文本框中显示文本单击按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有问题.. 在aspx形式有一个文本框和三个按钮.单击每个按钮时,文本框将显示不同的文本.并且所有按钮单击事件都会在aspx.cs文件中调用相同的功能.
i have a some problem.. in a aspx form have a textbox ans three buttons. on clicking each button textbox display different text. and all buttons click event call same function in aspx.cs file. how do it.. plse help me..
推荐答案如果要调用相同的函数,则必须传递一个参数来指示哪个button_click事件调用该函数. 那只有我能从您的问题中提出建议 If you are calling a same function then you have to pass one parameter to indicate which button_click event calling that function. that only i can suggest from your question
那是什么问题?您可以使用按钮的ID进行检查. 试试这个: Then what is the problem? You can check with the ID of the button. Try this: protected void buttonGroup_Click(object sender, EventArgs e) { Button btn = (Button)sender; if(btn.ID == "Button1") TextBox1.Text = "Button1 clicked"; else if(btn.ID == "Button2") TextBox1.Text = "Button2 clicked"; else if(btn.ID == "Button3") TextBox1.Text = "Button3 clicked"; }
希望对您有所帮助.! --Amit
Hope it helps.! --Amit
protected void buttonGroup_Click(object sender, EventArgs e) { Button btn = (Button)sender; if(btn.ID == "Button1") TextBox1.Text = "Button1 clicked"; else if(btn.ID == "Button2") TextBox1.Text = "Button2 clicked"; else if(btn.ID == "Button3") TextBox1.Text = "Button3 clicked"; }
更多推荐
如何在文本框中显示文本单击按钮
发布评论