0

So, basically I have a simple asp.net page "Default.aspx" that has a textbox called "txt"and button "adjust_btn" and an iFrame that is linked to "preview.aspx" which has "label1" in header.

Here is the code I have for Default.aspx:

<p>
<asp:Button ID="preview_btn" runat="server" Text="Preview" Width="110px" OnClick="preview_btn_Click" />
 <asp:TextBox ID="txt" runat="server" Width="200px" Height="25px"></asp:TextBox>
</p>

Here's the code I have in "Preview.aspx":

<h1> <asp:Label ID="Label1" runat="server" Text="Label1"></asp:Label> </h1>

Here's the code i have for the button click:

protected void preview_btn_Click(object sender, EventArgs e)
{
iframe.Visible= true;
// here i want something that does this iframe.label1 = textbox1.Text; 
// so the label1 is in iframe and the textbox1 is in the main page..
}

Appreciate your help, team!

Unheilig
  • 15,690
  • 193
  • 65
  • 96
Junior John
  • 145
  • 10
  • You can't do this in server side code, not in the way you want. There is no `iFrame.label1` in the code-behind, because the iframe is hosting a different page. If the pages are in the same domain you can use JavaScript on the client to do this, or you're looking at possibly using websockets or SignalR. – sh1rts Oct 14 '15 at 03:20
  • yes I do have both pages in my Solution Explorer and they will be on the same domain, can you please guide me on the JavaScript code for the client side. – Junior John Oct 14 '15 at 11:00
  • StackOverflow has a search function you could use, or this if you don't want to - http://stackoverflow.com/questions/1088544/javascript-get-element-from-within-an-iframe – sh1rts Oct 15 '15 at 04:55

0 Answers0