Hi Friends,
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...
In the above code OnClientClick attribute method is working fine and Click EventHandler is not working
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...
Code:
LinkButton lnkbtnDel = new LinkButton();
lnkbtnDel.Text = "Delete";
lnkbtnDel.ID = "lnkDel" + i.ToString();
lnkbtnDel.Attributes.Add("runat", "server");
[B]lnkbtnDel.Click += new EventHandler(Dynamic_Click);[/B]
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;");
Code:
protected void Dynamic_Click(object sender, EventArgs e)
{
Page.ClientScript.RegisterStartupScript(Type.GetType("System.String"), "OK", "<script language='javascript'>alert('Expected');</script>");
}
Comment