Click here to Skip to main content
15,920,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 :
XML
<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>


my iframe code :
XML
<iframe runat="server" id="iframe1" src=""
    style="height: 300px; width: 635px" frameborder="0"></iframe>


Any ideas?
Posted

XML
<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>
 
Share this answer
 
v2
Comments
Dalek Dave 3-Sep-10 4:49am    
Good Call.
good answer upstaires :laugh:
But I suggest the code
onclick='document.getElementById("<%=iframe1.ClientID%>").src = this.href; return false;

can be assigned in Grid_RowDataBound event handler.

It's good for separation between code and HTML.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900