如何在文本框中显示文本单击按钮

编程入门 行业动态 更新时间:2024-10-27 04:28:58
本文介绍了如何在文本框中显示文本单击按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有问题.. 在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"; }

更多推荐

如何在文本框中显示文本单击按钮

本文发布于:2023-05-25 01:47:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/265211.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本   单击   框中   按钮   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!