And the following back code:
[code]
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("http://www.google.com/search?hl=en&q=" + TextBox1.Text.ToString() + "");
}
[/code]
The back code runs as a new page in browser,where keyword entered in
TextBox1 redirect to new google page to search for the keyword entered
in TextBox1.Now i want the back code function runs on the iframe,where the same function runs on the iframe.
Any ideas?
Bryian TanPosted Aug 25, 2010, 9:02 AM
try create a new page with the name TestIframe.aspx, paste the below code in it
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestIframe.aspx.cs" Inherits="TestIframe" %>
Then paste the following codes in the TestIframe.aspx.cs file
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class TestIframe : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
iframe1.Attributes.Add("src", "http://www.google.com/search?hl=en&q=" + TextBox1.Text + "");
}
}
Rupesh PawarPosted Aug 19, 2015, 6:56 AM
samPosted Aug 25, 2010, 8:50 PM
samPosted Aug 25, 2010, 3:21 AM
SharrangasPosted Aug 25, 2010, 3:06 AM
Try this in .cs.
HtmlGenericControl googlesearchiframe = (HtmlGenericControl)Page.Master.FindControl("iframe");
if(googlesearchiframe!=null)
{
googlesearchiframe.Attributes("src") = "http://www.google.com/search?hl=en&q=" + TextBox1.Text + "";
}
samPosted Aug 25, 2010, 2:08 AM
am i missing some arguments?
or the i frame code should include asp tag?
Bryian TanPosted Aug 25, 2010, 1:34 AM
Do you have on your .aspx page?
samPosted Aug 24, 2010, 11:55 PM
It shows the following error when i use your code;
The name 'iframe1' does not exist in the current context
I even tried the code by opening in new page.
Bryian TanPosted Aug 24, 2010, 11:21 PM
You can try something like below.
.aspx
.cs
protected void Button1_Click(object sender, EventArgs e)
{
iframe1.Attributes.Add("src", "http://www.google.com/search?hl=en&q=" + TextBox1.Text + "");
}