I've a div
<div id="PageContent" runat="server"></div>
Now I'm adding HTML to it from code behind(c#) like this
PageContent.InnerHtml =mytext;
where mytext
is the content I want to add in PageContent
div, mytext contains a span in between some text(it can be any string), something like this
This is some <span id="span1"> </span> text
How can I find span from code behind and add user control to it?
//This is some <span id="span1" runat="server"> </span>
//In the code behind...
var span1 = this.FindControl("span1") as HtmlGenericControl;
var controlPath = "path of your user control";
var someControl = LoadControl(controlPath);
span1.Controls.Add(someControl);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With