I have a small query. I am working on ASP.NET with C#. I am trying to implement a dynamic link on my web page using C# code and from that link OnClick event i need to call a Click EventHandler method. My below Code is not working. Help me... Thanks in advance...
Expand|Select|Wrap|Line Numbers
- LinkButton lnkbtnDel = new LinkButton();
- lnkbtnDel.Text = "Delete";
- lnkbtnDel.ID = "lnkDel" + i.ToString();
- lnkbtnDel.Attributes.Add("runat", "server");
- lnkbtnDel.Click += new EventHandler(Dynamic_Click);
- lnkbtnDel.OnClientClick = "confirm('Are you sure you want to delete this permanently');";
- lnkbtnDel.CommandName = "DeleteReq";
- lnkbtnDel.Font.Size = 7;
- lnkbtnDel.Attributes.Add("style", "position:relative;bottom:3px;padding-bottom:3px;color:red;");
Expand|Select|Wrap|Line Numbers
- protected void Dynamic_Click(object sender, EventArgs e)
- {
- Page.ClientScript.RegisterStartupScript(Type.GetType("System.String"), "OK", "<script language='javascript'>alert('Expected');</script>");
- }