0

Hi! I have a problem on my program.. I created a dynamic button which i created during runtime and im done with that.. My problem is i dont know how to put codes in that button which i created dynamically. When i click the button i want to display an aspx page. Help me guys..

3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by hollystyles
0

Assuming that your button is on one page and you want to link to another, you can just set the PostBackUrl attribute to your destination:

<asp:Button ID="Button1" runat="server" PostBackUrl="someotherpage.aspx" Text="foo" />
0

OP is creating it dynamically so do Infarction's suggestion but in your code behind wherever you are building it.

using System.Web.UI.WebControls.
:

public partial class ... blah
{
private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
                        Button btn = new Button();
                        btn.ID = "button1";
                        btn.PostBackUrl = "somepage.aspx";
                        Page.Controls.Add(btn);

:
:
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.