Thursday 16 January 2014

Add image on div

<asp:FileUpload ID="uploadImage" runat="server" onchange="readURL(this);" CssClass="CFC_NormalTextBox" TabIndex="3" />
                    <div id="DivNewPreview" >
                    <div id="imgPrev" runat="server">
                   
                    </div>
                    </div>

function readURL(input) {
        if (input.files && input.files[0]) {
            var reader = new FileReader();

            reader.onload = function (e) {

                var str21 = '<img style="width:100px; height:125px;padding: 2px; border: 1px solid Silver" src="' + e.target.result + '" >';
                $("#DivNewPreview").html(str21);
            }
            reader.readAsDataURL(input.files[0]);
        }
    }

Thursday 5 December 2013

ASP.NET Jquery set tabs dynamically

<style type="text/css">
    #tabs
    {
        margin: 0;
        padding: 0;
        list-style: none;
        overflow: hidden;
    }
    #tabs li
    {
           border-radius: 4px 4px 0 0;
           -webkit-border-radius: 4px 4px 0 0;
           -moz-border-radius: 4px 4px 0 0;
           -os-border-radius: 4px 4px 0 0;
    color: #666666 !important;
    display: block;
    float: left;
    margin-right: 4px;
    padding: 5px;
    background:none repeat scroll 0 0 #CECECE;
    }
    #tabs li a
    {
        /*color: #484848;
        text-decoration: none;
        line-height: 2.5;
        padding:20px;*/
        color:#666666;
        font-family: 'Oswald',"Trebuchet MS","Myriad Web Pro",arial,serif;
    font-size: 18px;
    font-weight: normal;
    line-height: 1.8;
    padding: 16px;
    }
    #tabs li.current
    {
        background:none repeat scroll 0 0 #3F3F3F !important
    }
    #tabs li.current a
    {
        color: #fff;
        text-decoration: none;
       
    }
    #tabs li a.remove
    {
        color: #f00;
        margin-left: 10px;
    }
    .contentTabs
    {
       
        padding: 0;
        border:1px solid #C1C1C1;
         box-shadow: 0 0 5px #CCCCCC;
    }
       
    #main
    {
        /*width: 900px;*/
        margin: 0px auto;
        overflow: hidden;
        /*background-color: #F6F6F6;*/
        /*margin-top: 20px;*/
        -moz-border-radius: 10px;
        -webkit-border-radius: 10px;
        /*padding: 30px;*/
    }
    #wrapper, #doclist
    {
        float: left;
        margin: 0 20px 0 0;
    }
   
    #documents
    {
        margin: 0;
        padding: 0;
    }
   
    #wrapper
    {
        clear: both;
   
  
    width: 100%;
    }
    .Mng_content{  margin: 0 auto;
    max-height: 147px;
    min-height: 146px;
    padding: 1px;}
    .Mng_content:hover{ border:1px solid #4B960E;}
</style>
<script type="text/javascript">
    $(document).ready(function () {

        $('[id$=_content]:eq(2) .Mng_content:eq(1)').css("background-color", "#E2DFDF");
        $('#tabs a.tab').live('click', function () {
            // Get the tab name
            debugger;
            var contentname = "#" + $(this).attr("id") + "_content";

            //alert(contentname);
            // hide all other tabs
            $(".contentTabs").hide();
            $("#tabs li").removeClass("current");

            // show current tab
            $(contentname).show();
            $(this).parent().addClass("current");
            //            $(this).css("display", "block");
            //            $(this).children("div").css("display", "block");
        });


    });
   
</script>
<div id="datadiv">
    <div id="main">
        <div id="wrapper">
            <ul id="tabs">
                <ul id="listTabs" runat="server">
                    <!-- Tabs go here -->
                   
                </ul>
            </ul>
            <div id="content"  runat="server">
                <!-- Tab content goes here -->
               
            </div>
        </div>
    </div>
</div>



protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    //loadfulldata();
                    //LoadNetworkingdata();
                    //LoadonDmande();
                    LoadTabs();
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }


void LoadTabs()
        {

            DataSet ds=objTabController.GetManageTab();
            List<TabName> myojb = new List<TabName>();
            List<TabRecord> myojbWhole = new List<TabRecord>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {

                myojb.Add(new TabName()
                {

                    Name = dr["TabName"].ToString(),
                    ID = Convert.ToInt32(dr["TabId"].ToString())

                });

            }
            string  Record = string.Empty;
            string _ulString=string.Empty;
            int count=0;
            string _FullRecord=string.Empty;

            string tblRec =string.Empty;

            foreach (TabName obj in myojb)
            {
                DataSet dsRecord=objTabController.GetTabContentByTabID(obj.ID);
                count += 1;
                if (count == 1)
                {
                    _ulString += "<li class='current'><a id='" + obj.ID + "' class='tab' style='cursor:pointer;'>" + obj.Name + "</a></li>";
                    tblRec = "<div id='" + obj.ID + "_content' style='display: block;' class='contentTabs'>";
                }
                else
                {
                    _ulString += "<li class=''><a id='" + obj.ID + "' class='tab'  style='cursor:pointer;'>" + obj.Name + "</a></li>";
                    tblRec = "<div id='" + obj.ID + "_content' style='display: none;' class='contentTabs'>";
                }







                string Contentdiv = string.Empty;
                foreach (DataRow dr in dsRecord.Tables[0].Rows)
                {
                    //string content1=;
                    //Contentdiv += "<div id='" + dr["Image"].ToString() + "_content' style='display: none;'><table>";
                    Contentdiv += "<div class='Mng_content'><table><tr><td><a style='text-decoration: none;' href='" + dr["Url"].ToString() + "'><img id='"+ dr["Header"].ToString()+"_imgid'  src='/images/" + dr["Image"].ToString() + "' style='height: 100px !important; max-width: 100px !important; margin-right:10px;cursor:pointer;'></img></a></td><td><a style='text-decoration: none;' href='" + dr["Url"].ToString() + "'><h2 style='cursor:pointer;'>" + dr["Header"].ToString() + "</h2></a><p>" + Server.HtmlDecode(dr["Contents"].ToString()) + "</p></td></tr></table></div>";

                }
                _FullRecord +=tblRec + Contentdiv+"</div>";
            }
            content.InnerHtml = _FullRecord;
            listTabs.InnerHtml = _ulString;

        }

DotNetNuke: Creating a new parent portal Using C#
DotNetNuke: Importing Template for new portal From Parent Portal


                           DotNetNuke: Creating a new parent portal Using C#
                           DotNetNuke: Importing Template for new portal From Parent Portal


<script type="text/javascript">
    $(document).ready(function () {
        $("span[id*=dnnTITLE1_titleLabel]").hide();
        var url1 = '<%=url1 %>';
        var x = $('input[id$=txtClientPortal]').val();
        url1 = url1 + '/' + x;
        $('a[id$=txtclientview]').click(function () {

            window.open(url1);
            return false;
        });
    });
    function isNumber(evt) {
        var iKeyCode = (evt.which) ? evt.which : evt.keyCode
        if (iKeyCode != 46 && iKeyCode > 31 && (iKeyCode < 48 || iKeyCode > 57))
            return false;

        return true;
    }

  
 
</script>
<%--<style>
    .register_1 input
    {
        border: 1px solid #CCCCCC;
        margin: 8px 0 8px 30px;
        padding: 3px;
        width: 250px;
    }
    .register_1 span
    {
        color: #000000;
        font-size: 12px;
    }
    .register_1 select
    {
        border: 1px solid #CCCCCC;
        margin: 8px 0 8px 30px;
        width: 170px;
    }
   
    p
    {
        margin: 0;
    }
    @media screen and (-webkit-min-device-pixel-ratio:0)
    {
        .register_1 select
        {
            border: 1px solid #CCCCCC;
            margin: 8px 0;
            width: 157px;
        }
    }
   
    /* IE6, IE7, IE8 */
    .register_1 td
    {
        text-align: left\9;
    }
   
    .register_1 select
    {
        width: 155px\9;
    }
</style>--%>
<div class="dnnFormItem">
   
    <asp:Label ID="lblTemplateDescription" runat="server" />
</div>
<div id="rowType" runat="server" class="dnnFormItem">
    <dnn:label id="plType" runat="server" controlname="optType" />
    <asp:RadioButtonList ID="optType" CssClass="dnnFormRadioButtons" runat="server" RepeatDirection="Horizontal"
        RepeatLayout="Flow" AutoPostBack="True" Visible="false">
        <asp:ListItem resourcekey="Parent" Value="P" />
        <asp:ListItem resourcekey="Child" Value="C" />
    </asp:RadioButtonList>
</div>
<div id="useCurrentPanel" runat="server" class="dnnFormItem">
    <dnn:label id="useCurrentLabel" runat="server" controlname="useCurrent" />
    <asp:CheckBox ID="useCurrent" runat="server" AutoPostBack="true" Checked="true" Visible="false" />
</div>
<fieldset id="MngCaption">

    <legend style="font-size: 14px; font-family: Arial; font-weight: bold;">
        <asp:Label ID="lblcreateclient" runat="server" Text="Create New Client"></asp:Label><asp:Label
            ID="lblclientname" runat="server" Text=""></asp:Label></legend>
    <div style="margin-left: 35px;">
        <table class="register_1">
        <tr>
                <td>
                    <asp:Label ID="Label1" runat="server" Text="Template"></asp:Label>
                </td>
                <td colspan="3">
                    <dnn:label id="plTemplate" runat="server" controlname="cboTemplate" />
    <dnn:DnnComboBox id="cboTemplate" runat="server" Visible="true" AutoPostBack="true"
        CausesValidation="False" />
                </td>
               
            </tr>

            <tr>
                <td>
                    <asp:Label ID="lblClientPortal" runat="server" Text="Client Portal"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtweburl" runat="server" Enabled="false" Width="178px" Font-Bold="true"
                        CssClass="CFC_NormalTextBox" />
                    <asp:TextBox ID="txtClientPortal" runat="server" Style="margin-left: -9px; width: 155px;"
                        CssClass="CFC_NormalTextBox" />
                    <asp:RequiredFieldValidator ID="reqclientportal" runat="server" ControlToValidate="txtClientPortal"
                        Display="Dynamic" ForeColor="Red" ErrorMessage="Please fill Client Portal"></asp:RequiredFieldValidator>
                </td>
                <td>
                    <asp:LinkButton ID="txtclientview" runat="server" Text="View" Visible="false" OnClick="txtclientview_Click"
                        class="_btnsubmit"></asp:LinkButton>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblPortalNo" runat="server" Text="Client Portal No."></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtPortalNo" runat="server" onkeypress="javascript:return isNumber (event)"
                        CssClass="CFC_NormalTextBox" Width="343px" />
                    <asp:RequiredFieldValidator ID="RequiredFieldPortalno" runat="server" ControlToValidate="txtPortalNo"
                        Display="Dynamic" ForeColor="Red" ErrorMessage="Please fill Client Portal No."></asp:RequiredFieldValidator>
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblBusinessName" runat="server" Text="College Name"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtBusinessName" runat="server" CssClass="CFC_NormalTextBox" Width="343px" />
                    <asp:RequiredFieldValidator ID="RequiredFieldbname" runat="server" ControlToValidate="txtBusinessName"
                        Display="Dynamic" ForeColor="Red" ErrorMessage="Please fill Business Name"></asp:RequiredFieldValidator>
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblCollegeSeries" runat="server" Text="College Series"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtCollegeSeries" runat="server" CssClass="CFC_NormalTextBox" Width="343px" />
                    <asp:RequiredFieldValidator ID="reqCollegeSeries" runat="server" ControlToValidate="txtCollegeSeries"
                        Display="Dynamic" ForeColor="Red" ErrorMessage="Please fill College Series"></asp:RequiredFieldValidator>
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblcollegelogo" runat="server" Text="College Logo"></asp:Label>
                </td>
                <td>
                    <asp:FileUpload ID="fileimage" runat="server" CssClass="CFC_NormalTextBox" />
                    <%-- <asp:RequiredFieldValidator ID="reqcollegelogo" runat="server" ControlToValidate="txtcollegelogo"
                        Display="Dynamic" ForeColor="Red" ErrorMessage="Please Upload College Logo"></asp:RequiredFieldValidator>--%>
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>
            <%-- <tr>
                <td colspan="2">
                    <<asp:Label ID="lblAddressInfo" Style="font-size: 14px; font-family: Arial; font-weight: bold;"
                        runat="server" Text="Address Information"></asp:Label>
                </td>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>--%>
            <tr>
                <td>
                    <asp:Label ID="lblAddress" runat="server" Text="Organization Address"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtAddress" runat="server" CssClass="CFC_NormalTextBox" Width="343px" />
                    <asp:RequiredFieldValidator ID="RequiredFieldaddress" runat="server" ControlToValidate="txtAddress"
                        Display="Dynamic" ForeColor="Red" ErrorMessage="Please fill Address"></asp:RequiredFieldValidator>
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblCity" runat="server" Text="Organization City"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtCity" runat="server" CssClass="CFC_NormalTextBox" Width="343px" />
                    <asp:RequiredFieldValidator ID="RequiredFieldcity" runat="server" ControlToValidate="txtCity"
                        Display="Dynamic" ForeColor="Red" ErrorMessage="Please fill City"></asp:RequiredFieldValidator>
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblState" runat="server" Text="Organization State"></asp:Label>
                </td>
                <td>
                    <asp:DropDownList ID="ddlState" runat="server" CssClass="CFC_NormalTextBox" Width="200px">
                        <asp:ListItem Text="--Select--"></asp:ListItem>
                        <asp:ListItem Text="Alaska"></asp:ListItem>
                        <asp:ListItem Text="California"></asp:ListItem>
                        <asp:ListItem Text="Florida"></asp:ListItem>
                        <asp:ListItem Text="New York"></asp:ListItem>
                        <asp:ListItem Text="Texas"></asp:ListItem>
                        <asp:ListItem Text="Virginia"></asp:ListItem>
                    </asp:DropDownList>
                    <asp:RequiredFieldValidator ID="RequiredFieldstate" runat="server" ControlToValidate="ddlState"
                        Display="Dynamic" ForeColor="Red" ErrorMessage="Please Select State" InitialValue="--Select--"></asp:RequiredFieldValidator>
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblZip" runat="server" Text="Organization Zipcode"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtZip" runat="server" CssClass="CFC_NormalTextBox" Width="343px"
                        onkeypress="javascript:return isNumber (event)" />
                    <asp:RequiredFieldValidator ID="RequiredFieldzip" runat="server" ControlToValidate="txtZip"
                        Display="Dynamic" ForeColor="Red" ErrorMessage="Please fill Zip"></asp:RequiredFieldValidator>
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td colspan="3">
                          <asp:Label ID="lblAddressInfo" Style="font-size: 14px; font-family: Arial; font-weight: bold; display:none;"
                        runat="server" Text="Address Information"></asp:Label>
                        <br />
                </td>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblSponsoredby" runat="server" Text="Sponsored by"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtSponsoredby" runat="server" CssClass="CFC_NormalTextBox" Width="343px" />
                    <asp:RequiredFieldValidator ID="reqSponsoredby" runat="server" ControlToValidate="txtSponsoredby"
                        Display="Dynamic" ForeColor="Red" ErrorMessage="Please fill Sponsored by"></asp:RequiredFieldValidator>
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblWebsite" runat="server" Text="College Website"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtWebsite" runat="server" CssClass="CFC_NormalTextBox" Width="343px" />
                    <asp:RequiredFieldValidator ID="RequiredFieldwebsite" runat="server" ControlToValidate="txtWebsite"
                        Display="Dynamic" ForeColor="Red" ErrorMessage="Please fill Website"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionwebsite" runat="server" ControlToValidate="txtWebsite"
                        ForeColor="Red" ValidationExpression="http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&amp;=]*)?"
                        ErrorMessage="Please fill valid Website"></asp:RegularExpressionValidator>
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblPhone" runat="server" Text="College Phone Number"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtPhone" runat="server" CssClass="CFC_NormalTextBox" Width="343px"
                        onkeypress="javascript:return isNumber (event)" />
                    <asp:RequiredFieldValidator ID="RequiredFieldphone" runat="server" ControlToValidate="txtPhone"
                        Display="Dynamic" ForeColor="Red" ErrorMessage="Please fill Phone Number"></asp:RequiredFieldValidator>
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>
            <%-- <tr>
                <td colspan="2">
                    <asp:Label ID="lblPrimary" Style="font-size: 14px; font-family: Arial; font-weight: bold;"
                        runat="server" Text="Primary Contact"></asp:Label>
                </td>
                <td>
                </td>
                <td>
                </td>
            </tr>--%>
            <tr>
                <td>
                    <asp:Label ID="lblContactName" runat="server" Text="Primary Contact Name"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtContactName" runat="server" CssClass="CFC_NormalTextBox" Width="343px" />
                    <asp:RequiredFieldValidator ID="RequiredFieldcontactname" runat="server" ControlToValidate="txtContactName"
                        Display="Dynamic" ForeColor="Red" ErrorMessage="Please fill Contact Name"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lbltitle" Style="margin-left: 1px;" runat="server" Text="Primary Contact Title"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtTitle" runat="server" CssClass="CFC_NormalTextBox" Width="343px" />
                    <asp:RequiredFieldValidator ID="RequiredFieldtitle" runat="server" ControlToValidate="txtTitle"
                        Display="Dynamic" ForeColor="Red" ErrorMessage="Please fill Title"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblEmail" runat="server" Text="Primary Contact Email"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtEmail" runat="server" CssClass="CFC_NormalTextBox" Width="343px" />
                    <asp:RequiredFieldValidator ID="RequiredFieldemail" runat="server" ControlToValidate="txtEmail"
                        Display="Dynamic" ForeColor="Red" ErrorMessage="Please fill Email"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmail"
                        ForeColor="Red" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                        ErrorMessage="Please fill valid Email"></asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblPhonePrimary" Style="margin-left: 3px;" runat="server" Text="Primary Contact Phone Number"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtPhonePrimary" runat="server" CssClass="CFC_NormalTextBox" Width="343px"
                        onkeypress="javascript:return isNumber (event)" />
                    <asp:RequiredFieldValidator ID="RequiredFieldphoneprimary" runat="server" ControlToValidate="txtPhonePrimary"
                        Display="Dynamic" ForeColor="Red" ErrorMessage="Please fill Phone Number"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" class="_btnsubmit"
                        OnClientClick="Form.target=''" />
                </td>
                <td>
                </td>
                <td>
                    <asp:Button ID="btnCancel" runat="server" Text="Cancel" Style="margin-left: -406px;"
                        OnClick="btnCancel_Click" class="_btnsubmit" CausesValidation="false" OnClientClick="Form.target=''" />
                </td>
                <td>
                </td>
            </tr>
        </table>
    </div>
</fieldset>
<%--<span id="msgrslt" runat="server" forecolor="Red"></span>--%>
<asp:Label ID="msgrslt" runat="server" ForeColor="Green"></asp:Label>



 protected void btnSave_Click(object sender, EventArgs e)
        {

int portalID = CreateProtal();


}
protected int CreateProtal()
        {
            intPortalId = 0;
            string strPortalNAme = txtBusinessName.Text.ToString().Trim();
            string str_PortalAlias = txtClientPortal.Text.ToString().Trim();
            string str_HomeDirectory = "Portals/[PortalID]";
            string str_Description = "DNN";
            string str_KeyWords = "ChildPortal";

            if (true)
            {
                PortalController.PortalTemplateInfo template = LoadPortalTemplateInfoForSelectedItem();


                try
                {

                    bool blnChild;
                    string strPortalAlias;
                    string strChildPath = string.Empty;
                    var closePopUpStr = string.Empty;



                    //check template validity
                    var messages = new ArrayList();
                    string schemaFilename = Server.MapPath(string.Concat(AppRelativeTemplateSourceDirectory, "/Template/portal.template.xsd"));
                    string xmlFilename = template.TemplateFilePath;
                    var xval = new PortalTemplateValidator();
                    if (!xval.Validate(xmlFilename, schemaFilename))
                    {
                        DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "", String.Format(Localization.GetString("InvalidTemplate", LocalResourceFile), Path.GetFileName(template.TemplateFilePath)), ModuleMessage.ModuleMessageType.RedError);
                        messages.AddRange(xval.Errors);
                       
                    }

                    //Set Portal Name
                    str_PortalAlias = str_PortalAlias.ToLowerInvariant();
                    str_PortalAlias = str_PortalAlias.Replace("http://", "");

                    //Validate Portal Name
                    if (!Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
                    {
                        blnChild = true;
                        strPortalAlias = str_PortalAlias;
                    }
                    else
                    {
                        blnChild = (optType.SelectedValue == "C");

                        strPortalAlias = blnChild ? PortalController.GetPortalFolder(str_PortalAlias) : str_PortalAlias;
                    }

                    string message = String.Empty;
                    ModuleMessage.ModuleMessageType messageType = ModuleMessage.ModuleMessageType.RedError;
                    if (!PortalAliasController.ValidateAlias(strPortalAlias, blnChild))
                    {
                        message = Localization.GetString("InvalidName", LocalResourceFile);
                    }

                    //check whether have conflict between tab path and portal alias.
                    var checkTabPath = string.Format("//{0}", strPortalAlias);
                    if (TabController.GetTabByTabPath(PortalSettings.PortalId, checkTabPath, string.Empty) != Null.NullInteger)
                    {
                        message = Localization.GetString("DuplicateWithTab", LocalResourceFile);
                    }


                    string strServerPath = Globals.GetAbsoluteServerPath(Request);

                    //Set Portal Alias for Child Portals
                    if (String.IsNullOrEmpty(message))
                    {
                        if (blnChild)
                        {
                            strChildPath = strServerPath + strPortalAlias;

                            if (Directory.Exists(strChildPath))
                            {
                                message = Localization.GetString("ChildExists", LocalResourceFile);
                            }
                            else
                            {
                                if (!Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
                                {
                                    strPortalAlias = Globals.GetDomainName(Request, true) + "/" + strPortalAlias;
                                }
                                else
                                {
                                    strPortalAlias = str_PortalAlias;
                                }
                            }
                        }
                    }

                    //Get Home Directory
                    string homeDir = str_HomeDirectory != @"Portals/[PortalID]" ? str_HomeDirectory : "";

                    //Validate Home Folder
                    if (!string.IsNullOrEmpty(homeDir))
                    {
                        if (string.IsNullOrEmpty(String.Format("{0}\\{1}\\", Globals.ApplicationMapPath, homeDir).Replace("/", "\\")))
                        {
                            message = Localization.GetString("InvalidHomeFolder", LocalResourceFile);
                        }
                        if (homeDir.Contains("admin") || homeDir.Contains("DesktopModules") || homeDir.ToLowerInvariant() == "portals/")
                        {
                            message = Localization.GetString("InvalidHomeFolder", LocalResourceFile);
                        }
                    }
                   
                    //Validate Portal Alias
                    if (!string.IsNullOrEmpty(strPortalAlias))
                    {
                        PortalAliasInfo portalAlias = PortalAliasController.GetPortalAliasLookup(strPortalAlias.ToLower());
                        if (portalAlias != null)
                        {
                            message = Localization.GetString("DuplicatePortalAlias", LocalResourceFile);
                        }
                    }

                    //Create Portal
                    if (String.IsNullOrEmpty(message))
                    {
                        //Attempt to create the portal
                        UserInfo adminUser = new UserInfo();

                        try
                        {
                            if (useCurrent.Checked)
                            {
                                adminUser = UserInfo;
                                adminUser.Membership.Password = UserController.GetPassword(ref adminUser, String.Empty);
                            }
                            else
                            {
                              


                            }
                            intPortalId = objPortalController.CreatePortal(strPortalNAme,
                                                                           adminUser,
                                                                           str_Description,
                                                                           str_KeyWords,
                                                                           template,
                                                                           homeDir,
                                                                           strPortalAlias,
                                                                           strServerPath,
                                                                           strChildPath,
                                                                           true);
                        }
                        catch (Exception ex)
                        {
                            intPortalId = Null.NullInteger;
                            message = ex.Message;
                        }
                       



                      
                    }
                    DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "", message, messageType);
                }
                catch (Exception exc) //Module failed to load
                {
                    Exceptions.ProcessModuleLoadException(this, exc);
                }
            }
            return intPortalId;
        }
        public PortalController.PortalTemplateInfo LoadPortalTemplateInfoForSelectedItem()
        {
            var values = cboTemplate.SelectedItem.Value.Split('|');

            return TestablePortalController.Instance.GetPortalTemplate(Path.Combine(TestableGlobals.Instance.HostMapPath, values[0]), values.Length > 1 ? values[1] : null);
        }

        void BindTemplates()
        {
            var templates = TestablePortalController.Instance.GetAvailablePortalTemplates();
            templates = templates.OrderBy(x => x, new TemplateDisplayComparer()).ToList();


            foreach (var template in templates)
            {
                var item = CreateListItem(template);
                cboTemplate.AddItem(item.Text, item.Value);
            }

            SelectADefaultTemplate(templates);

            if (cboTemplate.Items.Count == 0)
            {
                DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "", Localization.GetString("PortalMissing", LocalResourceFile),
                                                 ModuleMessage.ModuleMessageType.RedError);
                // cmdUpdate.Enabled = false;
            }
            //cboTemplate.InsertItem(0, Localization.GetString("None_Specified"), "");
            //cboTemplate.SelectedIndex = 0;

        }

        void SelectADefaultTemplate(IList<PortalController.PortalTemplateInfo> templates)
        {
            string currentCulture = Thread.CurrentThread.CurrentUICulture.Name;

            var defaultTemplates =
                templates.Where(x => Path.GetFileNameWithoutExtension(x.TemplateFilePath) == "Default Website").ToList();

            var match = defaultTemplates.FirstOrDefault(x => x.CultureCode == currentCulture);
            if (match == null)
            {
                match = defaultTemplates.FirstOrDefault(x => x.CultureCode.StartsWith(currentCulture.Substring(0, 2)));
            }
            if (match == null)
            {
                match = defaultTemplates.FirstOrDefault(x => String.IsNullOrEmpty(x.CultureCode));
            }

            if (match != null)
            {
                cboTemplate.SelectedIndex = templates.IndexOf(match);
            }
        }
        class TemplateDisplayComparer : IComparer<PortalController.PortalTemplateInfo>
        {
            public int Compare(PortalController.PortalTemplateInfo x, PortalController.PortalTemplateInfo y)
            {
                var cultureCompare = String.Compare(x.CultureCode, y.CultureCode, StringComparison.CurrentCulture);
                if (cultureCompare == 0)
                {
                    return String.Compare(x.Name, y.Name, StringComparison.CurrentCulture);
                }

                //put blank cultures last
                if (string.IsNullOrEmpty(x.CultureCode) || string.IsNullOrEmpty(y.CultureCode))
                {
                    cultureCompare *= -1;
                }
                return cultureCompare;
            }
        }
        private CultureDropDownTypes DisplayType { get; set; }

        ListItem CreateListItem(PortalController.PortalTemplateInfo template)
        {
            string text, value;
            if (string.IsNullOrEmpty(template.CultureCode))
            {
                text = template.Name;
                value = Path.GetFileName(template.TemplateFilePath);
            }
            else
            {
                if (DisplayType == 0)
                {
                    string _ViewType = Convert.ToString(DotNetNuke.Services.Personalization.Personalization.GetProfile("LanguageDisplayMode", "ViewType" + PortalId));
                    switch (_ViewType)
                    {
                        case "NATIVE":
                            DisplayType = CultureDropDownTypes.NativeName;
                            break;
                        case "ENGLISH":
                            DisplayType = CultureDropDownTypes.EnglishName;
                            break;
                        default:
                            DisplayType = CultureDropDownTypes.DisplayName;
                            break;
                    }
                }

                text = "Default Website - English (United States)";//string.Format("{0} - {1}", template.Name, Localization.GetLocaleName(template.CultureCode, DisplayType))
                value = string.Format("{0}|{1}", Path.GetFileName(template.TemplateFilePath), template.CultureCode);
            }

            return new ListItem(text, value);
        }