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


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?


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.

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

Here are the details:

this.iframeMain.Attributes["src"] = "";

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

Need Your Help

Looking to arrive at a usable solution for password salting in a PHP/MySQL application?

php passwords hash salt

After reading about password hashing/salting for an entire day (no lie!), I'm in need of arriving at a solution that works, can be used consistently, and is about secure enough for a variety of dif...

Making Array From Page Elements in jQuery

javascript jquery html arrays object

I have a huge HTML select list that has a bunch of options. Some of the options have a 'parent' attribute which I'm using to identify. Basically, when someone picks the parent dropdown, all of it's

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.