When you manually instantiate a server control, there's no need to add the runat="server" attribute. This is a special attribute that's used only by the ASP.NET page parser to distinguish server controls from other markup.
The OnClick attribute in markup corresponds to the Click server-side event, which you hook up using the += operator.
So:
LinkButton lb = new LinkButton();
lb.ID = "LinkButton1";
lb.Click += click_event;
lb.Text = "testtext";
And the event handler
protected void click_event(object sender, EventArgs e)
{
}
In this example there is no need to add runat server because it already has it.
Have a look at this answer: https://stackoverflow.com/a/11337397/284240