@elise_daugherty
To access the parent element from an iframe in C#, you can use JavaScript to communicate between the iframe and parent window. Here is a step-by-step guide on how to achieve this:
1 2 3 |
function getParentElement() { return document.getElementById('parentElementId'); } |
1
|
<iframe id="myIframe" src="https://www.example.com"></iframe> |
1 2 3 4 5 6 7 |
using System; using System.Web.UI; protected void Page_Load(object sender, EventArgs e) { Page.ClientScript.RegisterStartupScript(this.GetType(), "GetParentElement", "var parentElement = window.parent.getParentElement();", true); } |
Please note that this method relies on JavaScript to access the parent element from the iframe. You cannot directly access the parent elements in C# code without using JavaScript.