mohamed mohamed - 6 months ago 87
ASP.NET (C#) Question

how to access iframe textbox id in current page?

Friends I have a Parent Page(default.aspx) that includes an iframe page(iframe.aspx) containing textbox in the field. The parent page contains the "Save" button. Now i want to get the values of iframe page while submitting the parent page. How can i access the iframe pages fields in parent page submit?

iframe.aspx page,,,,
In Iframe page i have two textbox,,

<asp:textbox id="txtfromdate" runat="server"></asp:textbox>
<asp:textbox id="txttodate" runat="server"></asp:textbox>

default.aspx page

<iframe id="iframebody" runat="server" src="iframe.aspx" style="width:900px; height:600px"></iframe>

<asp:button id="submit" text="save" runat="server" />

frdz how to access iframe page id(txtfromdate, txtTodate) in parrent page(default.aspx) when i click on button??


Try this javascript on the button click.


<input type="hidden" id="txtHidData" runat="server" />


var iframe = document.getElementById('iframebody');
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
var usernameTextBox = innerDoc.getElementById('txtfromdate');
document.getElementById ( "txtHidData" ).value = usernameTextBox.value;


string valueInCodeBehind = txtHidData.Value;