public string ConvertRelativeUrlToAbsoluteUrl(string relativeUrl, HttpRequest Request, System.Web.UI.Page page)
 {
     if (Request.IsSecureConnection)
         return string.Format("https://{0}{1}{2}", Request.Url.Host, ":"+Request.Url.Port, page.ResolveUrl(relativeUrl));
     else
         return string.Format("http://{0}{1}{2}", Request.Url.Host, ":" + Request.Url.Port, page.ResolveUrl(relativeUrl));
 }
Exemple #2
0
    /// <summary>
    /// Please note that the database connection must be properly set up before calling this function
    /// </summary>
    /// <param name="contactId"></param>
    /// <param name="request"></param>
    /// <returns></returns>
    public static string DisplayContact(long contactId, System.Web.UI.Page page)
    {
        VolunteerTracker.Person person = new VolunteerTracker.Person(contactId);
        string editLink = "<a href=\"" + page.ResolveUrl("~/People/Person.aspx?id=" + person.Id) + "&return=" + System.Uri.EscapeUriString(page.Request.RawUrl) + "\">Edit</a>";
        string deleteLink = "<a href=\"" + page.ResolveUrl("~/People/DeletePerson.aspx?id=" + person.Id) + "&return=" + System.Uri.EscapeUriString(page.Request.RawUrl) + "\" onclick=\"javascript: return confirm('Delete?')\">Delete</a>";
        if(!person.ACL.CanWrite(VolunteerTracker.Database.GetUserId()))
        {
            editLink = "";
            deleteLink = "";
        }

        string html = @"<fieldset>
                <legend>
                    Key Contact " + (editLink != "" ?  "(" + editLink + ", " + deleteLink + ")" : "") +
                @"</legend>";

        if (person.ACL.NoAccess(VolunteerTracker.Database.GetUserId()))
        {
            html = @"<fieldset>
                        <legend>
                            Key Contact
                        </legend>
                        We're sorry you do not have have permission to view this contact. Please ask your account administrator for help
                        </fieldset>";
            return html;
        }

        if(person.Name != ""){
            html += "<b>Name</b> &nbsp;" + person.Name;
        }

        if (person.Title != "")
        {
            html += "<br/><b>Title</b> &nbsp;" + person.Title;
        }
        if(person.OfficePhone != ""){
        html += "<br/><b>Bus. Tele.</b> &nbsp;" + person.OfficePhone;
        }
        if(person.CellPhone != ""){
        html += "<br/><b>Cell Phone</b> &nbsp;" + person.CellPhone;
        }
        if(person.HomePhone != ""){
        html += "<br/><b>Home Phone</b> &nbsp;" + person.HomePhone;
        }
        if(person.Fax != ""){
        html += "<br/><b>Fax Tele.</b> &nbsp;" + person.Fax;
        }
        if(person.Email != ""){
        html += "<br/><b>Email</b> &nbsp;" + person.Email;
        }
        if (person.Address != "")
        {
            html += "<br/><b>Address</b> &nbsp;" + person.Address;
        }

        html += "</fieldset>";
        return html;
    }
Exemple #3
0
 /// <summary>
 /// This function is used to get full http url from a relative url
 /// </summary>
 /// <param name="CurrentPage">Current page object</param>
 /// <param name="RelativeUrl">Relative url to get</param>
 /// <returns>Full http url (absolute url)</returns>
 public static string GetAbsoluteUrl(System.Web.UI.Page CurrentPage, string RelativeUrl)
 {
     if (CurrentPage.Request.Url.Port.Equals(80))
     {
         return CurrentPage.Request.Url.Scheme + "://" + CurrentPage.Request.Url.Port
                 + CurrentPage.Request.Url.Host + CurrentPage.ResolveUrl(RelativeUrl);
     }
     else
     {
         return CurrentPage.Request.Url.Scheme + "://"
                     + CurrentPage.Request.Url.Host + CurrentPage.ResolveUrl(RelativeUrl);
     }
 }
Exemple #4
0
        public static string GetContentPageMenu(System.Web.UI.Control page, string path)
        {
            if(page != null)
            {
                string menu = string.Empty;
                Collection<MixERP.Net.Common.Models.Core.Menu> rootMenus = MixERP.Net.BusinessLayer.Core.Menu.GetRootMenuCollection(path);

                if(rootMenus.Count > 0)
                {
                    foreach(MixERP.Net.Common.Models.Core.Menu rootMenu in rootMenus)
                    {

                        menu += string.Format(System.Threading.Thread.CurrentThread.CurrentCulture, "<div class='sub-menu'><div class='menu-title'>{0}</div>", rootMenu.MenuText);

                        Collection<MixERP.Net.Common.Models.Core.Menu> childMenus = MixERP.Net.BusinessLayer.Core.Menu.GetMenuCollection(rootMenu.MenuId, 2);

                        if(childMenus.Count > 0)
                        {
                            foreach(MixERP.Net.Common.Models.Core.Menu childMenu in childMenus)
                            {
                                menu += string.Format(System.Threading.Thread.CurrentThread.CurrentCulture, "<a href='{0}' title='{1}' data-menucode='{2}' class='sub-menu-anchor'>{1}</a>", page.ResolveUrl(childMenu.Url), childMenu.MenuText, childMenu.MenuCode);
                            }
                        }

                        menu += "</div>";
                    }
                }

                return menu;
            }

            return null;
        }
Exemple #5
0
        public static string GetPageMenu(System.Web.UI.Page page)
        {
            if(page != null)
            {
                string menu = string.Empty;

                Collection<MixERP.Net.Common.Models.Core.Menu> menuCollection = MixERP.Net.BusinessLayer.Core.Menu.GetMenuCollection(page.Request.Url.AbsolutePath, 1);

                if(menuCollection.Count > 0)
                {
                    foreach(MixERP.Net.Common.Models.Core.Menu model in menuCollection)
                    {
                        menu += string.Format(System.Threading.Thread.CurrentThread.CurrentCulture, "<div class='menu-panel'><div class='menu-header'>{0}</div><ul>", model.MenuText);

                        Collection<MixERP.Net.Common.Models.Core.Menu> childMenus = MixERP.Net.BusinessLayer.Core.Menu.GetMenuCollection(model.MenuId, 2);

                        if(childMenus.Count > 0)
                        {
                            foreach(MixERP.Net.Common.Models.Core.Menu childMenu in childMenus)
                            {
                                menu += string.Format(System.Threading.Thread.CurrentThread.CurrentCulture, "<li><a href='{0}' title='{1}'>{1}</a></li>", page.ResolveUrl(childMenu.Url), childMenu.MenuText);
                            }
                        }

                        menu += "</ul></div>";
                    }
                }

                menu += "<div style='clear:both;'></div>";
                return menu;
            }

            return null;
        }
		public override void OnPreInit(System.Web.UI.Page page, ContentItem item)
		{
			if (string.IsNullOrEmpty(page.MasterPageFile))
				return;

			if (!string.IsNullOrEmpty(configuredMasterPagePath))
				page.MasterPageFile = configuredMasterPagePath;

			var defaultUrl = page.ResolveUrl(page.MasterPageFile);
			var alternateUrl = engine.ResolveAdapter<RequestAdapter>(item).ResolveTargetingUrl(defaultUrl);
			if (!string.Equals(alternateUrl, defaultUrl, System.StringComparison.InvariantCultureIgnoreCase))
				page.MasterPageFile = alternateUrl;
		}
Exemple #7
0
    public static string GetUrl(System.Web.UI.Page control, string relativePath)
    {
        string protocol = control.Page.Request.IsSecureConnection ? "https" : "http";

        string host = control.Page.Request.Url.Host;

        if (!((protocol == "http" && control.Page.Request.Url.Port == 80) || (protocol == "https" && control.Page.Request.Url.Port == 443)))
        {
          host += ":" + control.Page.Request.Url.Port;
        }

        return string.Format("{0}://{1}{2}",
          protocol,
          host,
          control.ResolveUrl(relativePath)
        );
    }
Exemple #8
0
        public static string GenMenus(System.Web.UI.Page p)
        {
            StringBuilder sb_menus = new StringBuilder();
            string absolute_url = p.Request.Url.AbsolutePath;
            System.Collections.Generic.List<string> lMenus = new System.Collections.Generic.List<string>();
            //lMenus.Add("1,Home.aspx,Home|Home.aspx");
            lMenus.Add("1,WebService/Index.aspx,Web Service|WebService/Index.aspx,WebService/Projects.aspx,WebService/Edit.aspx");
            lMenus.Add("1,Database/Index.aspx,Database|Database/Index.aspx,Database/Projects.aspx,Database/Template.aspx,Database/Edit.aspx");
            lMenus.Add("1,XML/Index.aspx,XML Tools|XML/Index.aspx,XML/Edit.aspx");
            if (SessionHelper.GetCurrentSession().UserCode == "127.0.0.1")
                lMenus.Add("1,Tools/SVN/Index.aspx,SVN Tools|Tools/SVN/Index.aspx,Tools/SVN/BackupChangedFiles.aspx");

            //lMenus.Add("1,Downloads/Index.aspx,Downloads|Downloads/Index.aspx");
            string resolve_url = p.ResolveUrl("~");
            bool isFirst = true;
            foreach (string s in lMenus)
            {
                string[] menu_info = s.Split('|');
                string[] menu_detail = menu_info[0].Split(',');
                string[] menu_page_ref = menu_info[1].Split(',');
                bool is_find_active_page = false;
                if (!isFirst) sb_menus.Append("<li class=\"mm-split\">|</li>");
                foreach (string pr in menu_page_ref)
                {
                    if (absolute_url.ToLower().EndsWith(pr.ToLower()))
                    {
                        sb_menus.Append(string.Format(MAIN_MENU_ACTIVE, resolve_url, menu_detail[1], menu_detail[2]));
                        is_find_active_page = true;
                        isFirst = false;
                        break;
                    }
                }
                if (!is_find_active_page)
                {
                    sb_menus.Append(string.Format(MAIN_MENU, resolve_url, menu_detail[1], menu_detail[2]));
                    isFirst = false;
                }
            }
            return sb_menus.ToString();
        }
Exemple #9
0
    public static string CreateMenuItemHtml(System.Web.UI.Page page, Dictionary<string, string> item, string className, bool isDropdown)
    {
        string currentPage = GetCurrentPage(page.Request, Convert.ToInt32(item["SegmentNumber"]));
        string path = item["Path"];
        string filename = item["Filename"];
        string arguments = item["Arguments"];
        string displayName = item["DisplayName"];
        string id = item["Id"];
        string title = item["Title"];
        string baseUrl = page.ResolveUrl(path + "/" + filename);
        bool externalLink = Boolean.Parse(item["ExternalLink"]);
        if (externalLink)
        {
        baseUrl = path + "/" + filename;
        }
        if (!externalLink && currentPage == id)
          {
          if (!isDropdown)
          {
              return "<a class=\"" + currentDirectoryClass + "\" id=\"" + id + "\" title=\"" + title + "\" href=\"" + baseUrl + arguments + "\">" + displayName + "</a> &nbsp; ";//displayName + " &nbsp;&nbsp;";
          }
          else
          {
              return "<a id=\"" + id + "\" title=\"" + title + "\" href=\"" + baseUrl + arguments + "\">" + displayName + "</a>";//displayName + " &nbsp;&nbsp;";
          }
          }
        else
        {

        if (!isDropdown)
        {
            return "<a id=\"" + id +  "\" title=\"" + title + "\" class=\"" + plainDirectoryClass + "\" " + " href=\"" + baseUrl + arguments + "\">" + displayName + "</a> &nbsp; ";
        }
        else
        {
            return "<a id=\"" + id + "\" title=\"" + title + "\"" + " href=\"" + baseUrl + arguments + "\">" + displayName + "</a> ";
        }

        }
    }
Exemple #10
0
 /// <summary>
 /// 加载CSS样式文件
 /// </summary>
 public static string CSS(string cssPath, System.Web.UI.Page p)
 {
     return @"<link href=""" + p.ResolveUrl(cssPath) + @""" rel=""stylesheet"" type=""text/css"" />" + "\r\n";
 }
Exemple #11
0
 /// <summary>
 /// 加载javascript脚本文件
 /// </summary>
 public static string JS(string jsPath, System.Web.UI.Page p)
 {
     return @"<script type=""text/javascript"" src=""" + p.ResolveUrl(jsPath) + @"""></script>" + "\r\n";
 }
    /// <summary>
    /// Loads the fancybox script.</summary>
    /// <param name="page">The web page.</param>
    public static void LoadLibrary_FancyBox(System.Web.UI.Page page)
    {
        System.Web.UI.HtmlControls.HtmlGenericControl mousewheelScript = new System.Web.UI.HtmlControls.HtmlGenericControl("script");
        mousewheelScript.Attributes["type"] = "text/javascript";
        mousewheelScript.Attributes["src"] = page.ResolveUrl("~/design/libraries/jquery/fancybox/jquery.mousewheel-3.0.2.pack.js");
        page.Header.FindControl("phHeader").Controls.Add(mousewheelScript);

        System.Web.UI.HtmlControls.HtmlGenericControl fancyboxScript = new System.Web.UI.HtmlControls.HtmlGenericControl("script");
        fancyboxScript.Attributes["type"] = "text/javascript";
        fancyboxScript.Attributes["src"] = page.ResolveUrl("~/design/libraries/jquery/fancybox/jquery.fancybox-1.3.1.pack.js");
        page.Header.FindControl("phHeader").Controls.Add(fancyboxScript);

        System.Web.UI.HtmlControls.HtmlLink fancyboxSCSS = new System.Web.UI.HtmlControls.HtmlLink();
        fancyboxSCSS.Href = page.ResolveUrl("~/design/libraries/jquery/fancybox/jquery.fancybox-1.3.1.css");
        fancyboxSCSS.Attributes.Add("rel", "stylesheet");
        fancyboxSCSS.Attributes.Add("type", "text/css");
        fancyboxSCSS.Attributes.Add("media", "screen");
        page.Header.FindControl("phHeader").Controls.Add(fancyboxSCSS);
    }
    /// <summary>
    /// Loads the colorpicker script.</summary>
    /// <param name="page">The web page.</param>
    public static void LoadLibrary_ColorPicker(System.Web.UI.Page page)
    {
        System.Web.UI.HtmlControls.HtmlGenericControl colorpickerScript = new System.Web.UI.HtmlControls.HtmlGenericControl("script");
        colorpickerScript.Attributes["type"] = "text/javascript";
        colorpickerScript.Attributes["src"] = page.ResolveUrl("~/design/libraries/jquery/colorpicker/js/colorpicker.js");
        page.Header.FindControl("phHeader").Controls.Add(colorpickerScript);

        System.Web.UI.HtmlControls.HtmlLink colorpickerCSS = new System.Web.UI.HtmlControls.HtmlLink();
        colorpickerCSS.Href = page.ResolveUrl("~/design/libraries/jquery/colorpicker/css/colorpicker.css");
        colorpickerCSS.Attributes.Add("rel", "stylesheet");
        colorpickerCSS.Attributes.Add("type", "text/css");
        page.Header.FindControl("phHeader").Controls.Add(colorpickerCSS);
    }
Exemple #14
0
        /// <summary>
        /// Adds a new script tag to the page header prior to the page being rendered
        /// </summary>
        /// <param name="page">Current <see cref="System.Web.UI.Page"/></param>
        /// <param name="path">Path to script file.  Should be relative to layout template.  Will be resolved at runtime</param>
        public static void AddScriptLink( System.Web.UI.Page page, string path )
        {
            string relativePath = page.ResolveUrl( path );

            bool existsAlready = false;

            if ( page != null && page.Header != null )
                foreach ( Control control in page.Header.Controls )
                {
                    if ( control is LiteralControl )
                        if ( ( ( LiteralControl )control ).Text.ToLower().Contains( "src=" + relativePath.ToLower() ) )
                        {
                            existsAlready = true;
                            break;
                        }

                    if ( control is HtmlGenericControl )
                    {
                        HtmlGenericControl genericControl = ( HtmlGenericControl )control;
                        if ( genericControl.TagName.ToLower() == "script" &&
                           genericControl.Attributes["src"] != null &&
                                genericControl.Attributes["src"].ToLower() == relativePath.ToLower() )
                        {
                            existsAlready = true;
                            break;
                        }
                    }
                }

            if ( !existsAlready )
            {
                HtmlGenericControl genericControl = new HtmlGenericControl();
                genericControl.TagName = "script";
                genericControl.Attributes.Add( "src", relativePath );
                genericControl.Attributes.Add( "type", "text/javascript" );

                page.Header.Controls.Add( new LiteralControl( "\n\t" ) );
                page.Header.Controls.Add( genericControl );
            }
        }
Exemple #15
0
        public static string GetProfileAvatarLink(
        System.Web.UI.Page page,
        object objUserId,
        int siteId,
        String avatar,
        String toolTip)
        {
            string result = string.Empty;
            if (objUserId != null)
            {
                int userId = Convert.ToInt32(objUserId);

                if ((avatar == null) || (avatar == String.Empty))
                {
                    avatar = "blank.gif";
                }
                String avaterImageMarkup = "<img title='" + toolTip
                + "'  alt='" + toolTip + "' src='"
                + page.ResolveUrl("~/Data/Sites/" + siteId.ToString(CultureInfo.InvariantCulture) + "/useravatars/" + avatar)
                + "' />";

                result = "<a title='" + toolTip + "' href='"
                + GetNavigationSiteRoot()
                + "/ProfileView.aspx?userid="
                + userId.ToString(CultureInfo.InvariantCulture) + "'>"
                + avaterImageMarkup + "</a>";
            }

            return result;
        }
Exemple #16
0
 public static string MsgBoxHtml(string text, System.Web.UI.Page page)
 {
     string MsgBoxFormat = "<table width=\"100%\"><tr><td align=\"center\"><table border=\"0px\" cellpadding=\"0px\" cellspacing=\"0px\" width=\"450px\"><tr><td class=\"ad-lt\" /><td class=\"ad-mt\" /><td class=\"ad-rt\" /></tr><tr><td class=\"ad-l\" /><td class=\"ad-bg\" align=\"left\" style=\"height: 100px;\"><table width=\"90%\" border=\"0\"><tr><td style=\"padding: 5px 10px 5px 10px; width: 10%\">{0}</td><td align=\"left\" style=\"width: 90%\">{1}</td></tr></table></td><td class=\"ad-r\" /></tr><tr><td class=\"ad-lb\" /><td class=\"ad-mb\" /><td class=\"ad-rb\" /></tr></table></td></tr></table>";
     string Img = "<img src=\"" + page.ResolveUrl("~") + "images/error1.gif\" alt=\"\" />";
     return string.Format(MsgBoxFormat, Img, text);
 }
 /// <summary>
 /// Loads the Galleria Script.</summary>
 /// <param name="page">The web page.</param>
 public static void LoadLibrary_Galleria(System.Web.UI.Page page)
 {
     System.Web.UI.HtmlControls.HtmlGenericControl galleriaScript = new System.Web.UI.HtmlControls.HtmlGenericControl("script");
     galleriaScript.Attributes["type"] = "text/javascript";
     galleriaScript.Attributes["src"] = page.ResolveUrl("~/design/libraries/jquery/aino-galleria/galleria.js");
     page.Header.FindControl("phHeader").Controls.Add(galleriaScript);
 }
Exemple #18
0
        /// <summary>
        /// Adds the CSS link.
        /// </summary>
        /// <param name="page">Current <see cref="System.Web.UI.Page"/></param>
        /// <param name="href">Path to css file.  Should be relative to layout template.  Will be resolved at runtime</param>
        /// <param name="mediaType">Type of the media to use for the css link.</param>
        public static void AddCSSLink( System.Web.UI.Page page, string href, string mediaType )
        {
            System.Web.UI.HtmlControls.HtmlLink htmlLink = new System.Web.UI.HtmlControls.HtmlLink();

            htmlLink.Attributes.Add( "type", "text/css" );
            htmlLink.Attributes.Add( "rel", "stylesheet" );
            htmlLink.Attributes.Add( "href", page.ResolveUrl( href ) );
            if ( mediaType != string.Empty )
                htmlLink.Attributes.Add( "media", mediaType );

            AddHtmlLink( page, htmlLink );
        }