How i can find webtab by its id and from other page.
For Eg - i have one page and on this page i want to get access of the WebTab that is defined into other page
Hi Arshi,
I guess your question is not related to WebTab, but to general approach to get references to javascript objects and html elements located in different windows/iframes.
That is possible only when those windows and created by your server (aspx pages). Otherwise, attempts to get document and other child objects will raise security exceptions.
I wrote for you an example.
1. Assume that you have aspx with WebTab and TextBox1 located in first tab and that aspx has name Temp3.aspx. That/those aspx page(s) is(are) located in iframes of another page and you know id(s) of those iframes:
<iframe id="iframe1" src="Temp3.aspx" width="350px" height="300px"></iframe><iframe id="iframe2" src="Temp3.aspx" width="350px" height="300px"></iframe>
2. Below is content of Temp3.aspx which has a button and on the button click application gets reference to parent window, child iframe (by id) which contains a child page which you search for. Now you may get reference to javascript objects located in that child iframe, its document, etc.Alert shows value of TextBox1 located in another page.Codes do not include validations for null, which must be used in a real project.To test: run parent page which contains definitions of iframes, enter values in editors of tabs and click buttons.
<ig:WebTab ID="WebTab1" runat="server" Width="300px" Height="200px"> <Tabs> <ig:ContentTabItem runat="server" Text="Tab 1"> <Template> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </Template> </ig:ContentTabItem> <ig:ContentTabItem runat="server" Text="Tab 2"></ig:ContentTabItem> </Tabs></ig:WebTab>
<script type="text/javascript"> function findTab(id) { var iframe = window.parent.document.getElementById(id); var doc = iframe.contentDocument; var win = iframe.contentWindow; var webTab1 = win.$find('WebTab1'); var tab0 = webTab1.getTabAt(0); var txt = tab0.findChild('TextBox1'); alert('textbox1:' + txt.value + '=' + doc.getElementById(txt.id).value); }</script><input type="button" value="Find Tab and Field on iframe1" onclick="findTab('iframe1')" /><input type="button" value="Find Tab and Field on iframe2" onclick="findTab('iframe2')" />