Reputation: 2281
I want to assign the html content to iframe control from asp.net code behind page;
this is working fine myIframe.Attributes.Add("src", "pathtofilewith.html"); but, i don't want to give the path of html file to display i just want to assign some html content which comes from database to iframe control.
i want some thing like this(Ashok) to be displayed in iframe control
i tried the bellow ways but nothing is succesful
myIframe.Attributes["innerHTML"] = "<h1>Thank You..</h1>";
myIframe.Attributes.Add("innerHTML", "<h1>Ashok</h1>");
Upvotes: 2
Views: 5796
Reputation: 19091
A way to communicate between two different pages where one is in an IFrame on the other, is to post data using JQuery. An example is given in this StackOverflow question
It is also discussed in this other StackOverflow question
On this page, you will also find a short and simple example of how you can put content in an IFrame without using a separate web-page for it (note the lacking src
attribute!).
Hope some of this helps!
Upvotes: 1
Reputation: 1
There is no way to insert HTML content into iframe tag directly, but you can create a page which gets the content form the database and then you can view it using iframe,
or
You can create a page for example called getContent.aspx which request value from the URL e.g. getContent.aspx?content=<h1>Thank You..</h1>
and display it wherever you like, and then call it from iframe.
Upvotes: 0
Reputation: 51494
You can't. That's not how an IFRAME
works - it is for use with the src attribute as you've already discovered.
Perhaps you want to create a DIV
instead
Upvotes: 0