Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
755
Setting name property of iframe created by splitterpane
posted

I use a websplitter. I set the ContentUrl of one of the splitterpanes. The other splitter pane contains html links, I want to target the html links to use the splitterpane. However the iframe rendered by the SplitterPane does not render a name attribute. Therefore my anchors cannot target the iframe.

 

  • 5
    posted

    A nice hack for this is to set the contenturl in the aspx page - but then remove it on load and add a control that contains the iframe

    protected void Page_Load(object sender, EventArgs e)

    {

    AddIdToSplitterPanelIFrame(wsMainContent.Panes[0]);

    }

    private void AddIdToSplitterPanelIFrame(Infragistics.Web.UI.LayoutControls.SplitterPane pane)

    {

    if (!String.IsNullOrEmpty(pane.ContentUrl))

    {

    string id = pane.ClientID;if (id.EndsWith(pane.ID))

    {

    id = id.TrimEnd(pane.ID.ToCharArray()) +
    "iframe";

    }

    string contentUrl = pane.ContentUrl;

    pane.ContentUrl = String.Empty;

    Literal lb = new Literal();

    lb.Text = "<iframe src='" + contentUrl + "' id='" + id + "' style='width:100%;height:100%;'></iframe>";

    pane.Controls.Add(lb);

    }

    }

     

    then you can get the id within the javascript via

     

    <script type="text/javascript" language="javascript">

     

    function goto(url)

    {

    document.getElementById(
    '<%= wsMainContent.Panes[0].ClientID.TrimEnd(wsMainContent.Panes[0].ID.ToCharArray()) + "iframe" %>').src = url;

    }

     

    </script>

    works for me - but obviously a dirty dirty hack - much better if the control had a ControlFrameId property that did that for you