Creating a Dynamic button from another Dynamic Button

Hi,

I have created a button Dynamically as follows:

Button b=new Button();

b.Text="Hello";

this.Controls.Add(b);

b.Show();

How to create another Button(some Button) when clicked on the above created button.

0
abdul
6/26/2008 10:21:39 AM
asp.net.web-forms 93655 articles. 5 followers. Follow

3 Replies
634 Views

Similar Articles

[PageSpeed] 50

You have to handle the on click event of the dynamic button. In the onclick event you can create another button in the same way as you have done. Remember to create the dynamic button on every post back other wise you will not be able to capture the click event..


Vikram
www.vikramlakhotia.com


Please mark the answer if it helped you
0
vik20000in
6/26/2008 10:31:23 AM

try this link:

http://support.microsoft.com/kb/317515


Regards,
Punithkumar
0
Punithkumar
6/26/2008 10:37:19 AM

Hi abdul,

You can try the following method.

protected void Page_Load(object sender, EventArgs e)
{
    Button dynamicButton = new Button();
    dynamicButton.ID = "dynamicButton";
    dynamicButton.Text = "dynamicButton";
    dynamicButton.Click += new EventHandler(dynamicButton_Click);
    this.Form.Controls.Add(dynamicButton);
}
protected void dynamicButton_Click(object sender, EventArgs e)
{
    //to create another button.
}


Let me know if I have misunderstood what you mean.
Thanks.
Hope it helps,
Hua Jun


Sincerely,
Hua Jun Li
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Hua
6/30/2008 3:25:55 AM
Reply:

Similar Artilces:

Please guide
Hi, I am creating dynamic panels and each of these panels have an image and a button. I would like to show a modal popup when the button of the panel is clicked. Contents of popup depend on which button was clicked. I would sincerely appreciate if some one could guide me if this is possible with Ajax and AjaxControltoolkit. Till now I tried to create modalpopupextended dynamically in the click event of button and page fails with an error message that TargetControl could not be found. Please guide. Regards & thanks Kapil    Hi Kapil, Unfortunately, the ModalPopup must h...

How to get the value of dynamically created text box which is created dynamically on click of button control.
<p>Dear AllI am new in asp.net.I am doing one project there I have one doubt.what I want is I have taken two  button controls in my page, in click of first button1 I have  dynamically created one textbox and I added this textbox to my page and also set the id for this textbox,.after that in click of second button2 I want that the value of the textbox will be print in my page by getting the value of the textbbox. some codes are given below. <form id="form1" runat="server">    <div>      ...

I Want to create a tool box,toolbox contains image button and fileupload.These two buttons can be added at runtime(user can add any number of image button and fileupload button dynamically by click)
I Want to create a tool box,toolbox contains image button and fileupload buttons.These two buttons can be added at runtime(user can add any number of image button and fileupload button dynamically by click).for every image user will browse images using fileuploader and he will add the image to that imagebutton at runtime. how to write server side coding to upload the selected image and to set that image to imagebutton at runtime? is it possible? any other way to do it?  advance thanks ask123: I Want to create a tool box,toolbox contains image button and fileupload b...

Dynamically created button & event handler for the button
I know that this question has been addressed a few times on these forums. I have looked over the posts that are refering to this process but I am still very confused. So I am posting here to see if someone could clear it up for me, I am a beginner at this so I must not be understanding previous posts. Here is the run down of what I am trying to accomplish. I have a page that has one button on it (button1) and a panel (panel1). When I click button1 I would like it to display another button (button2) on panel1. Then when you click button2 it will display a label on the panel. Panel1 a...

button.click for dynamically created button(Please help!)
Hi, I have a simple webform with only 2 web controls (panel1 and button1) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim _btn As Button = New Button _btn.Text = "Submit" _btn.Visible = True _btn.ID = "btnSubmit" AddHandler _btn.Click, AddressOf Me.submitBtnClicked Me.Panel1.Controls.Add(_btn) End Sub Private Sub submitBtnClicked(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim s As String = &q...

how to create button controls dynamically .. then i need that click event of buttons
how to create button controls  dynamically .. then i need that click event of buttons  urgent ???????Vino  Add dynamic controls with eventsWebsite Design Darlington - http://mdssolutions.co.ukhttp://lessthandot.com - Experts, Information, Ideas & Knowledgehttp://aspnetlibrary.com - An online resource for professional ASP.NET developersPlease remember to click "Mark as Answer" on this post if it helped you refer below snippet..public partial class _Default : System.Web.UI.Page {    protected void Page_Load(object sender, EventArgs e)  ...

dynamic buttons, dynamic events
Here is the thing... i need to generate different links to a page from a database... like link a === goes to page1.aspx?id=1link b === goes to page1.aspx?id=2  but i dont want to pass the id through the url. i think one way is to create instead hyperlinks, is create dynamic buttons but how do i create differents event to each button? or is there another better way? thanxs a lot If I understand correctly, you're trying to create dynamic links based on id's in the database?I would use a Repeater/Datalist type control.  In the ItemTemplate, you could use a LinkButton ...

How do I create an event for a dynamically created button?
I have a button that is loaded onto the page dynamically (with another button click actually). I assign it an ID, etc in the code behind file, but since it isn't actually created until after the page loads, I cant assign it a click event: Compiler Error Message: BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types. Source Error: Line 169: End SubLine 170:Line 171: Protected Sub erase_0_Click(ByVal sender As...

dynamically create computed button column using getrow number as button.text
Hi, I'm trying to dynamically create a button column where the text on the button is the number I get from using the getrow() function. I'm sort of stuck on trying figure out the correct syntax to use with the create column command. So far, I have something like this in C#: dw1.Modify("create column(band=detail id=5 x=\"2662\" y=\"8\" height=\"64\" width=\"279\" edit.limit=5 alignment=\"0\" font.face=\"Tahoma\" font.height=\"-8\" font.weight=\"400\" font.charset=\"0\"...

Triggering Dynamic form & button created with Literal control
I'm working on a small project that uses Paypal's encrypted 'Add to Cart' buttons.  With what I am trying to do I want to be able to load these into a database and pick from them on the fly.  The button is contained within a form with a big encrypted section.  See below:<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" alt="Click here to add to your secure cart"> ...

Dynamically adding buttons to web form and wiring up the onclick event.
I have a web form that is generated at runtime with a number of dynamically created buttons. Creating the buttons is easy, but wiring them up is not. I would love to use the cold behind and a single onclick event. Then based on the id, I can call a single method that does an operation. Each button will perform the same tasks. The user can chose one of three tasks. I though I would either have a dropdown or three radio buttons for this. Alternatively, I could have some javascript, but I am not quiet sure how to post back with javascript and if all the buttons will make it more difficult. Does...

Creating Delete button for Dynamically created controls?
Hi, I have at long last been able to create controls dynamically. They even maintain state after a request.  (See code below). On clicking the Add button, this code basically creates 4 textboxes + 4 labels on the fly.  Here is the catch and a real challenge for asp.net gurus. Now that I have successfully built an "Add" functionality, I am finding myself in need of a delete button that would delete the last set of controls created per click. Here is my code. Any help would be greatly appreciated. Please bare with me as I learn.(For those who landed on my page through t...

dynamic created button
dynamically created below 2  buttons coming in single row I want second button in next row.Button btnPayment = new Button(); btnPayment.Text = "Payment";btnPayment.ID = "0"; string s = "<br />";Button btnPayment1 = new Button(); btnPayment1.Text = "Payment";btnPayment1.ID = "1"; btnPayment.Visible = true;btnPayment1.Visible = true; divButtons.Controls.Add(btnPayment);   divButtons.Controls.Add(btnPayment1); btnPayment.CommandArgument = "1";btnPayment.Command += new CommandEventHandler(btnPayment_Click)...

creating dynamic buttons
Hi,I'm trying to create paging for a picture gallery.  I have the next and previous buttons working, but I also wanted to put page numbers (i.e. 1 2 3....).  What I'm trying to do so far is get the number of pictures and since I want to display 15 pictures per page, I would donumberOfPages = totalPictures/15 and then use the ceil function on it to determine the number of pages I'll have.  However, I would need to create these dynamically, but I don't really know how I would do this.  Furthermore, these pages would need to be links or buttons that would fire an event...Tha...

Web resources about - Creating a Dynamic button from another Dynamic Button - asp.net.web-forms

Wikipedia:Creating a bot - Wikipedia, the free encyclopedia
It is often far simpler to request a bot job from an existing bot. If you have only periodic requests or are uncomfortable with programming languages, ...

U.K. Woman Faces 20 Months For Creating Fake Facebook Accounts, Sending Herself Abusive Messages
A woman in Cornwall in the U.K. came up with a creative way to use Facebook to accelerate a family spat, and it earned her 20 months in prison. ...

Sandi Krakowski’s Tips for Creating Great Content
Quick tips to help you create great content for your business.

Bug - Creating a Video.Watches Action stopped working - Facebook-Entwickler
Since today executing a POST on a me/video.wacthes endpoints no longer works, it was working around 10 hours ago since then the call always returns ...

Facebook simplifies process for creating repeat events
Facebook introduced a new feature for events this week that allows users to quickly create a similar event as one they previously hosted or attended. ...

The Obama campaign won by creating their own Facebook, with unique features for political campaigns.
... seen as too dangerous to nominate someone who is so thoroughly narcissistic, arrogant and dishonest. The Obama campaign won basically by creating ...

Creating A Road Map To Market Your Startup
Spreading the word can be challenging when you’re new to an industry, don’t have a big budget, and have little helpbut it’s possible.You’ll need ...

Dance Machine - The Fun Video Editor for Creating Music Videos to share on Instagram, Facebook, Vine ...
Get Dance Machine - The Fun Video Editor for Creating Music Videos to share on Instagram, Facebook, Vine, and Twitter on the App Store. See screenshots ...

Creating Economic Dynamism: Joseph E. Stiglitz
DAVOS/SWITZERLAND, 25JAN13 - Joseph E. Stiglitz, Professor, Columbia University, USA talks during the session 'Creating Economic Dynamism' at ...

YouTube - Super Human Abilities: Tila Tequila Creating Energy Balls & Electricity Out of Thin Air!
Veröffentlicht am 24.04.2013 Hey Guys! For a long time now I have been able to do some pretty supernatural things that most would consider "SUPER ...

Resources last updated: 1/6/2016 10:49:07 AM