Render data instead of link in iframe

In iframe we always render some other page like

<iframe runat="server" id="myIframe" src=""></iframe>

or via code behind (I am using c# as code behind)

myIframe.Attributes["src"] = ""

But what if I want to add some html content instead of page in iframe?

iframe has attribute “srcdoc” which can be used to show some html content

<iframe runat="server" id="myIframe" srcdoc="<h1></h1>"></iframe>

or in code behind

myIframe.Attributes["srcdoc"] = "<h1></h1>"