Call Event dynamically

Posted by Venkatesh under ASP.NET on 7/23/2011 | Points: 10 | Views : 1808 | Status : [Member] | Replies : 5
Hi,

I have 10 Link button controls are there which are generated dynamically.This link button text will be dynamically

So when i click on link button it navigates to another page. How to do this?

Thanks
Venkatesh.P




Responses

Posted by: A4u_6178 on: 7/23/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,
for creating dynamic linkbutton..
LinkButton link = new LinkButton();

link.ID = "lnkButton";
link.Text = "DynLinkButton";
link.Click += new System.EventHandler(testlink);
form1.Controls.Add(link);

To navigate to another page on click of linkbutton
protected void testlink(object sender, EventArgs e)

{
Response.Redirect("~/Default.aspx");
}

I hope this helps u..


Thanks & Regards,

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: RaviRanjanKr on: 7/23/2011 [Member] Starter | Points: 25

Up
0
Down
yeah! before accomplish your this task I will suggest you to learn some articles for getting clear Ideas about working Dynamic controls.
Link1-[ http://www.4guysfromrolla.com/articles/081402-1.aspx ] Dynamic Controls in ASP.NET
Link2-[ http://weblogs.asp.net/infinitiesloop/archive/2006/08/25/TRULY-Understanding-Dynamic-Controls-_2800_Part-1_2900_.aspx ] TRULY UNDERSTANDING DYNAMIC CONTROLS (PART 1)

well try and feel free to revert back with your Specific question as possible with your effort.

Thanks
Ravi Ranjan Kumar
http://raviranjankr.wordpress.com

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Graha on: 7/25/2011 [Member] Starter | Points: 25

Up
0
Down
hi,
In design page, add this code

<asp:Button runat='server' id='button1' Text='Click Me' Click='button1_Click' />
<asp:LinkButton runat='server' id='linkbutton1' Text='Click Me' Click='button1_Click' />

Code-Behind
protected void button1_Click(object sender, EventArgs e)
{ // some logic
Response.Redirect("Page2.aspx");
}

Just add the button and in its click handler do:

Response.Redirect("Page2.aspx");

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Venkatesh on: 7/25/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

Thanks for replying,

In my application i am using master page.I am using 10 link buttons based upon previous page selection. It should showing.

And also based upon link button i need redirect another page.

Suppose in previous page he selects 3, The next page appears 3 link buttons with different name.

So, When user clicks on second link button i need to redirect another page,or He clicks on 1 link button i need redirect to another page.

How to do this.

Thanks
Venkatesh.P

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jpchoudhari on: 7/26/2011 [Member] Starter | Points: 25

Up
0
Down
not clear what exactly you want to do and why

Kind Regards,
Jay

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response