Yes
<div runat="server"></div>
will make it a server side control. You can generate it in the code behind using
var myDiv = new HtmlGenericControl("div");
Edit: What you're generating is a server side control, there is no need to add runat="server"
.
Edit per comment:
<div onclick="alert('hello')" runat="server"></div>
or
var myDiv = new HtmlGenericControl("div");
myDiv.Attributes.Add("onclick", "alert('hello');");
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…