I am trying to convert my HTML String to control in C# asp.net and I am getting this below error "Exception Details: System.NullReferenceException: Object reference not set to an instance of an object."
I did searching since last five-6 hours. Already go through so many answers in the internet including Stackoverflow. But non of answers solved my query. Thanks in advance for replay
protected TextBox t2;
protected override void OnInit(EventArgs e)
{
String Str ="<input type="text" id="txtID" class="form-control" runat="server" />";
LiteralControl lt = new LiteralControl();
lt.Text = Str;
t1.Controls.Add(lt);
t2 = (TextBox)t1.FindControl("txtID");
t2.Text = "Maddsf";
}