Click here to Skip to main content
15,885,985 members
Articles / Web Development / ASP.NET

Hosting IFRAMEs using the JQuery UI Tabs plug-in - Part 1

Rate me:
Please Sign up or sign in to vote.
4.89/5 (20 votes)
23 Dec 2009CPOL9 min read 95.1K   1.9K   73  
Using JQuery UI Tabs to host web pages via IFRAMEs.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace HomeSite
{
    /// <summary>
    /// Content Loader code behind class
    /// </summary>
    public partial class ContentLoader : System.Web.UI.Page
    {
        /// <summary>
        /// On Page Load we need to capture query string parameters, construct
        /// an IFRAME element, and inject the IFRAME element into our Literal control
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            string id = "";
            string path = "";

            // Validate we have valid querystring parameters namely "ID" and "Path"
            if (HasValue(Request["ID"]) && HasValue(Request["Path"]))
            {
                // Set our local variables
                id = Request["ID"].Trim().ToString();
                path = Request["Path"].Trim().ToString();

                // Prepend the path URL with http:// if needed
                if (!path.ToLowerInvariant().StartsWith("http://"))
                    path = "http://" + path;

                // Construct the IFRAME element and set the Text value of the Literal control
                Literal1.Text = "<iframe class=\"contentsIframe\" id=\"contentFrame" + id + "\" frameborder=\"0\" src=\"" + path + "\"></iframe>";
            }
            else
            {
                // Either query parameter or both are not set or do not
                // exist (not passed as request parameters)
                Literal1.Text = "<span id=\"contentFrame\">An error occurred while attempting to load a web page.</span>";
            }

        }

        /// <summary>
        /// Simple static class used to validate the value of querystring
        /// parameter is not null or an empty string
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public static bool HasValue(object o)
        {
            if (o == null)
                return false;

            if (o is String)
            {
                if (((String) o).Trim() == String.Empty)
                    return false;
            }

            return true;
        }

    }

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer Intel Corporation
United States United States
I am an Automation Engineer specializing in application and web development/support.

Comments and Discussions