Arwinder Singh
Arwinder Singh

Reputation: 49

How to move a dynamically created button?

I have a Button1 and a textbox. When i put a value in textbox and click this button then a new button is created with the value filled in textbox but i want that when again i click Button1 and there should be one more button or we can say how to move previous button's position?

This is code for Button1 in .aspx.cs

protected void Button1_Click(object sender, EventArgs e) {

        Button btnNew = new Button();
        btnNew.ID = "btnNew";
        btnNew.Text = textBox1.Text;

        form1.Controls.Add(btnNew);
    }

Please help me to solve this. Thanks in advance.

Upvotes: 0

Views: 310

Answers (1)

ThomasArdal
ThomasArdal

Reputation: 5259

You could probably do something like this with JavaScript/jQuery:

$('#button1').click(function() {
    $('#button2').css('position', 'absolute');
    $('#button2').css('top', '50px');
});

etc. You should provide more info as suggested by Matt.

Upvotes: 0

Related Questions