创建动态按钮并添加面板或div [英] create dynamic button and add in panel or div
本文介绍了创建动态按钮并添加面板或div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何创建动态按钮并添加面板或div并在按钮单击中提供打开的链接?
How to create dynamic button and add in panel or div and give open link in button click ?
推荐答案
您是否尝试了任何方法?
步骤:
1.创建一个按钮
Did you try anything at all?
Steps:
1. Create a button
Button myButton = new Button();
myButton.ID = "myButton";
myButton.Text = "Click Me!";
2.将事件处理程序添加到按钮
2. Add the event handler to button
myButton.Click += new EventHandler(myButton_Click);
3.将按钮添加到面板或div
3. Add button to a panel or div
myPanel.Controls.Add(myButton);
4.从之前的代码后面定义一个按钮处理程序
4. Define a button handler in code behind from before
protected void myButton_Click(object sender, EventArgs e)
{
// Open a link or do whatever you like!
}
试试吧!
Try!
这篇关于创建动态按钮并添加面板或div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文