将链接的项目重定向到iframe [英] Redirect linked item to iframe
本文介绍了将链接的项目重定向到iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨.
我有一个代码,当我们将值插入文本框并单击提交按钮时,该值将临时显示在页面上的网格视图中,作为链接显示,它将值重定向到Google搜索.
现在我要在iframe中重定向页面.
这是当前代码:
Hi.
I have a code where when we insert value into textbox and click submit button,the value will be displayed in a gridview temporarily on the page as displayed as a link where it will redirect the value to google search.
Now i want the page redirect in iframe.
Here''s the current code :
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<a href='http://www.google.com/#q=<%#DataBinder.Eval(Container.DataItem,"name")%>'>
<%#DataBinder.Eval(Container.DataItem,"name")%></a>
</ItemTemplate>
</asp:TemplateField>
我的iframe代码:
my iframe code :
<iframe runat="server" id="iframe1" src=""
style="height: 300px; width: 635px" frameborder="0"></iframe>
有什么想法吗?
Any ideas?
推荐答案
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<a onclick='document.getElementById("<%=iframe1.ClientID%>").src = this.href; return false;' href='http://www.google.com/#q=<%#DataBinder.Eval(Container.DataItem,"name")%>'>
<%#DataBinder.Eval(Container.DataItem,"name")%></a>
</ItemTemplate>
</asp:TemplateField>
上等人的好答案:laugh:
但我建议使用代码
good answer upstaires :laugh:
But I suggest the code
onclick=''document.getElementById("<%=iframe1.ClientID%>").src = this.href; return false;
可以在Grid_RowDataBound事件处理程序中分配.
这对于将代码和HTML分开非常有用.
can be assigned in Grid_RowDataBound event handler.
It''s good for separation between code and HTML.
这篇关于将链接的项目重定向到iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文