Ahmed Atia
Ahmed Atia

Reputation: 17960

How to get an IFrame src attribute value from ASP.Net code behind?

Using

string iframeSrcPage = iframeMain.Attributes["src"];

to get iframe source, always returns the value which set in aspx page itself,
even that value is changed using javascript code,

iframeObject.src = pageURL;

So, how to get an IFrame src attribute value from ASP.Net code behind?

Upvotes: 2

Views: 12466

Answers (3)

user7584647
user7584647

Reputation:

it will work fine..

Iframe_id.Attributes.Add("src","YourPage.aspx?label="+123); 

Upvotes: 0

Traveling Tech Guy
Traveling Tech Guy

Reputation: 27811

Try this: add a hidden input field (with runat="server" attribute) and change its value to your IFrame's src in the JavaScript. That way, you'll be able to read the field's value server-side.

Upvotes: 3

WraithNath
WraithNath

Reputation: 18013

Just found this post, and another post with a better answer.

Here are the details:

this.iframeMain.Attributes["src"] = "http://www.stackoverflow.com";

Taken from: How can I access an IFRAME from the codebehind file in ASP.NET?

Upvotes: 1

Related Questions