how to get the src of a iframe

G

guoqi zheng

Dear sir,

I know how to set the src of a iframe, for example, I can use
Dim frame1 As HtmlControl = Page.FindControl("itest")
frame1.Attributes("src") = Me.TextBox1.Text.Trim

However how can I get the current src of a iframe after user clicking
several times on the iframe??? when I try to get the value of frame1.
Attributes("src"), what I get is the original src I set to it.

How can I do this?

regards,

Guoqi Zheng
http://www.ureader.com
 
B

Bruce Barker

this is only known at the client. you could use some ajax approach to notify
the server of a src change.

-- bruce (sqlwork.com)
 
I

intrader

Dear sir,

I know how to set the src of a iframe, for example, I can use
Dim frame1 As HtmlControl = Page.FindControl("itest")
frame1.Attributes("src") = Me.TextBox1.Text.Trim

However how can I get the current src of a iframe after user clicking
several times on the iframe??? when I try to get the value of frame1.
Attributes("src"), what I get is the original src I set to it.

How can I do this?

regards,

Guoqi Zheng
http://www.ureader.com
Tell me, while user click on the frame, what do you expect src to change?
 
Joined
Aug 9, 2006
Messages
2
Reaction score
0
Get the source property of IFrame

you need to do a findcontrol to identify the control on the page and typecast it as follows:-

C#
HtmlControl frame1 = (HtmlControl)this.FindControl("frame1");

VB.NET
Dim frame1 As HtmlControl = CType(Me.FindControl("frame1"), HtmlControl)

Note: You can have different name for the Generic Control you define in the code behind, but for ease I keep both the same. The "frame1" referred in Find Control is the ID as declared in the ASPX Page.

Thereafter, you will be able to access the src property as follows:-

C#
frame1.Attributes["src"] = http://megasolutions.net;

VB.NET
frame1.Attributes("src") = http://megasolutions.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,165
Latest member
JavierBrak
Top