在回发后动态添加的按钮处理事件

编程入门 行业动态 更新时间:2024-10-26 10:26:45
本文介绍了在回发后动态添加的按钮处理事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

基本上,我有,我有一个链接按钮更新面板,当用户点击链接按钮全部内容被清零,文本框显示在该用户输入的东西,当用户按下回车键键,更新面板应被刷新或者被更新或所有内容重新填充。

Basically, I have an update panel in which i have a link button, when user clicks on the link button all the contents are cleared and textbox shows up in which user enters something and when user hit enter key, the update panel should be refreshed or gets updated or repopulated with all the contents .

我该怎么办呢?

我试图做到这一点的方法是,当链接按钮的事件处理程序被激发,我创建了一个隐藏式按键动态,并为其分配一个新的事件处理程序,当用户点击进入key.This新的动态按钮将被解雇链接按钮事件处理中产生。在这个新的按钮事件处理,我会重新填充内容了。

The way I am trying to do this is that when event handler of link button is fired, I created a hidden button dynamically and assign it a new event handler which will get fired when user hits enter key.This new dynamic button is created inside link button event handler. In this new button event handler I will repopulate the contents back.

我的方法的问题是动态创建按钮的事件处理函数不是被解雇。为什么???

The problem with my way is the event handler of dynamically created button is not fired. Why ???

请尝试在C#来回答。先谢谢了。

Please try to answer in c#. Thanks in advance.

问候,

我的code#

protected void Submit_Click1(object sender, EventArgs e) { Label1.Text = TextBox1.Text + TextBox2.Text + " are sucessfully registered"; Button mento = new Button(); mento.cssclass = "invisible"; mento.Click += new EventHandler(mento_click); // here this new mento button is attached to update panel updatepanel1.ContentTemplateContainer.Controls.add(mento); }

现在的问题是mento_click事件处理程序不被解雇???

Now the problem is mento_click event handler does not get fired ???

推荐答案

您可以赶上回车键,在文本框中?

You can catch the enter key, in the textbox?

public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { //add event keydown textBox1.KeyDown += new KeyEventHandler(textBox1_KeyDown); } void textBox1_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode ) { case Keys.Enter: //YOur updatecode here: MessageBox.Show("You press enter"); break; default: break; } } }

更多推荐

在回发后动态添加的按钮处理事件

本文发布于:2023-10-12 20:49:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1485864.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按钮   事件   动态   回发后

发布评论

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

>www.elefans.com

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