嗨,是否可以在.cs文件中创建控件和事件。如果是的话,它是怎么回事。请帮我 [英] Hi, is that possible to create controls and events in .cs file.? if so, how it is . please help me
本文介绍了嗨,是否可以在.cs文件中创建控件和事件。如果是的话,它是怎么回事。请帮我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在.cs文件中创建控件和事件?如果是的话,它是怎么回事。请帮帮我。
我的代码是这样的
Hi, is that possible to create controls and events in .cs file ? if so, how it is . please help me .
my code is like this
this.Controls.Add(new TextBox { Text = "", ID = txtname.Text });
this.Controls.Add(new Button { Text = "Submit", ID = "btnsubmit"}),
这里我正在创建文本框控件。但它没有得到文本框值,我也怎么能创建事件按钮
提前,
谢谢。
here i am creating the textbox control . but it was not getting the textbox value and also how can i create event to button
in Advance ,
Thank you.
推荐答案
是的,确定。
在本网站的右上角,你会找到一个搜索框;在那里,您可以尝试键入类似c#controls或c#events的内容,并提供大量您可以学习的示例。不要犹豫,我们大多数人都用这种方法学到了很多东西。
QA并不是为了让你全面了解.NET中的控件和事件world。
Yes, sure.
In the top right corner of this site, you will find a search box; in there, you could try to type something like "c# controls" or "c# events", and be presented with tons of examples that you will be able to learn from. Don't hesitate, most of us have been learning a lot with this method.
QA are not meant to give you a full picture of controls and events in .NET world.
private TextBox txt;
protected void Page_Load(object sender, EventArgs e)
{
this.txt = new TextBox { Text = "", ID = "SomeID" };
this.Form.Controls.Add(this.txt);
Button btn = new Button { Text = "Submit", ID = "btnsubmit" };
btn.Click += btn_Click;
this.Form.Controls.Add(btn);
}
protected void btn_Click(object sender, EventArgs e)
{
string data = this.txt.Text;
}
这篇关于嗨,是否可以在.cs文件中创建控件和事件。如果是的话,它是怎么回事。请帮我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文