ResolveClientUrl() public method

public ResolveClientUrl ( string relativeUrl ) : string
relativeUrl string
return string
    protected void btnGo_Click(object sender, EventArgs e)
    {
        messageContent.InnerHtml = "";
        if (String.IsNullOrEmpty(txtRelatedID.Text.Trim()))
        {
            messageContent.InnerHtml = GetLocalResourceObject("Error3").ToString();
            return;
        }

        string strUrl = string.Empty;
        string strRelatedType = ddpRelated.SelectedValue.Trim();
        Control cl = new Control();
        switch (strRelatedType)
        {
            case "0":
                strUrl = cl.ResolveClientUrl("~/WebUI/DBQuery/LmSystemLogDetailPageByNew.aspx") + "?FOGID=";
                break;
            case "1":
                strUrl = cl.ResolveClientUrl("~/WebUI/Hotel/HotelInfoManager.aspx") + "?hid=";
                break;
            case "2":
                strUrl = cl.ResolveClientUrl("~/WebUI/Invoice/InvoiceManagerSearch.aspx") + "?CNF=";
                break;
            case "3":
                strUrl = cl.ResolveClientUrl("~/WebUI/UserGroup/UserDetailPage.aspx") + "?TYPE=1&ID=";
                break;
            case "4":
                strUrl = cl.ResolveClientUrl("~/WebUI/CashBack/CashApplProcess.aspx") + "?TYPE=1&ID=";
                break;
            case "5":
                strUrl = cl.ResolveClientUrl("~/WebUI/Feedback/UpdateAdviceStatus.aspx") + "?TYPE=1&id=";
                break;
            default:
                strUrl = "";
                break;
        }

        hidLinkUrl.Value = strUrl + txtRelatedID.Text.Trim();
        System.Web.UI.ScriptManager.RegisterClientScriptBlock(UpdatePanel1, typeof(UpdatePanel), "key", "window.open('" + hidLinkUrl.Value + "', null,'left=0,screenX=0,top=0,screenY=0,scrollbars=1,status=yes,toolbar=yes,menubar=yes,location=yes,resizable');", true);

        //this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "key", "PopupArea();", true);

        //this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "key", "PopupArea('" + strUrl + txtRelatedID.Text.Trim() + "');", true);
        //Response.Redirect(strUrl + txtRelatedID.Text.Trim());

        //StringBuilder script = new StringBuilder();

        //script.Append("<script type='text/javascript' language='JavaScript' >");
        //script.Append("window.open('" + strUrl + txtRelatedID.Text.Trim() + "')");
        //script.Append("</script>");

        //Page.ClientScript.RegisterStartupScript(this.GetType(), "report", script.ToString(), true);
    }
        protected override Control AddEditor(Control container)
        {
            var editor = base.AddEditor(container);
            Register.JavaScript(container.Page, Engine.ManagementPaths.ResolveResourceUrl("{ManagementUrl}/Resources/Js/jquery.editableThemeSelection.js"));

            StringBuilder initializationScript = new StringBuilder();
            initializationScript.AppendFormat("jQuery('#{0}').editableThemeSelection({{ '' : null", editor.ClientID);
            foreach (string directoryPath in GetThemeDirectories())
            {
                string thumbnailPath = Path.Combine(directoryPath, "thumbnail.jpg");
                string themeName = Path.GetFileName(directoryPath);
                if (File.Exists(thumbnailPath))
                {
                    initializationScript.AppendFormat(", '{0}' : '{1}'",
                        themeName,
                        container.ResolveClientUrl(string.Format("~/App_Themes/{0}/thumbnail.jpg", themeName)));
                }
                else
                {
                    initializationScript.AppendFormat(", '{0}' : null",
                        themeName);
                }
            }
            initializationScript.AppendFormat("}});");
            Register.JavaScript(container.Page, initializationScript.ToString(), ScriptOptions.DocumentReady);

            return editor;
        }
Example #3
0
        public void ResolveClientUrlTest() {
            AppDomainUtils.RunInSeparateAppDomain(() => {
                try {
                    Utils.CreateHttpContext("default.aspx", "http://localhost/WebSite1/subfolder1/default.aspx");
                    Utils.CreateHttpRuntime("/WebSite1/");

                    var control = new Control();
                    var result = control.ResolveClientUrl("~/world/test");
                    Assert.AreEqual("../world/test", result);
                }
                finally {
                    Utils.RestoreHttpContext();
                    Utils.RestoreHttpRuntime();
                }
            });
        }
        public static string MergeServiceUrls(string serviceUrl, string existingUrl, Control urlBase) {
            serviceUrl = serviceUrl.Trim();

            if(serviceUrl.Length > 0) {
                serviceUrl = urlBase.ResolveClientUrl(serviceUrl);

                if(String.IsNullOrEmpty(existingUrl)) {
                    // proxy has specified a url and we don't have one yet, so use it
                    existingUrl = serviceUrl;
                }
                else {
                    // proxy has specified a url but we arleady have a url either from ScriptManager itself or a previous proxy.
                    // The urls must agree or an exception is thrown.
                    if(!string.Equals(serviceUrl, existingUrl, StringComparison.OrdinalIgnoreCase)) {
                        throw new ArgumentException(AtlasWeb.AppService_MultiplePaths);
                    }
                }
            }
            return existingUrl;
        }
Example #5
0
		public static void ResolveClientUrl_Load (Page p)
		{
			Control ctrl = new Control ();
			p.Controls.Add (ctrl);
			string url = ctrl.ResolveClientUrl ("~/MyPage.aspx");
			Assert.AreEqual ("MyPage.aspx", url, "ResolveClientUrl Failed");

			Assert.AreEqual ("", ctrl.ResolveClientUrl (""), "empty string");
			
			Assert.AreEqual ("./", ctrl.ResolveClientUrl ("~"), "~");
			Assert.AreEqual ("./", ctrl.ResolveClientUrl ("~/"), "~/");

			Assert.AreEqual ("../MyPage.aspx", ctrl.ResolveClientUrl ("~/../MyPage.aspx"), "~/../MyPage.aspx");
			Assert.AreEqual ("../MyPage.aspx", ctrl.ResolveClientUrl ("~\\..\\MyPage.aspx"), "~\\..\\MyPage.aspx");
			Assert.AreEqual ("MyPage.aspx", ctrl.ResolveClientUrl ("~////MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveClientUrl ("/MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual ("/folder/MyPage.aspx", ctrl.ResolveClientUrl ("/folder/MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual ("/NunitWeb/MyPage.aspx", ctrl.ResolveClientUrl ("/NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual ("\\NunitWeb/MyPage.aspx", ctrl.ResolveClientUrl ("\\NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual ("///NunitWeb\\..\\MyPage.aspx", ctrl.ResolveClientUrl ("///NunitWeb\\..\\MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual ("NunitWeb/MyPage.aspx", ctrl.ResolveClientUrl ("NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual ("NunitWeb/../MyPage.aspx", ctrl.ResolveClientUrl ("NunitWeb/../MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual ("NunitWeb/./MyPage.aspx", ctrl.ResolveClientUrl ("NunitWeb/./MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual ("http://google.com/", ctrl.ResolveClientUrl ("http://google.com/"), "ResolveClientUrl Failed");

			Assert.AreEqual ("MyPage.aspx?param=val&yes=no", ctrl.ResolveClientUrl ("~/MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");
			Assert.AreEqual ("../MyPage.aspx?param=val&yes=no", ctrl.ResolveClientUrl ("~/../MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");

			Assert.AreEqual ("./MyPage.aspx", ctrl.ResolveClientUrl ("./MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual ("../MyPage.aspx", ctrl.ResolveClientUrl ("../MyPage.aspx"), "ResolveClientUrl Failed");
		
		}
    private void InitTree(string parentId, DataTable dt)
    {
        //DataView dv = new DataView();
        //TreeNode tmpNd;
        //string intId;

        //dv.Table = dt;
        //dv.RowFilter = "Parent_MenuId='" + parentId + "'";
        //foreach (DataRowView drv in dv)
        //{
        //    tmpNd = new TreeNode();
        //    //tmpNd.Target = "frm_right";
        //    tmpNd.Text = drv["Menu_Name"].ToString();
        //    tmpNd.NavigateUrl = drv["Menu_Url"].ToString();
        //    tmpNd.Value = drv["Menu_ID"].ToString();
        //    Nds.Add(tmpNd);

        //    intId = drv["Menu_ID"].ToString();
        //    InitTree(tmpNd.ChildNodes, intId, dt);
        //}

        System.Text.StringBuilder sbList = new System.Text.StringBuilder();
        //string intId;
        string RowFilter = "Parent_MenuId='" + parentId + "'";
        string RowDetailFilter = "";
        int iSpan = 0;
        foreach (DataRow drv in dt.Select(RowFilter))
        {
            sbList.Append("<h3 style='height:25px;'><a href='#'>");
            sbList.Append(drv["Menu_Name"].ToString());
            sbList.Append("</a></h3>");
            //intId = drv["Menu_ID"].ToString();
            sbList.Append("<div style='text-align:left;'>");

            RowDetailFilter = "Parent_MenuId='" + drv["Menu_ID"].ToString() + "'";

            foreach (DataRow drDetailRow in dt.Select(RowDetailFilter))
            {
                sbList.Append("<a href='");

                /**** 正式环境IIS 与 测试环境IIS 配置路径不同导致URL链接需要动态跳转 *****/
                //sbList.Append(Request.ApplicationPath + drDetailRow["Menu_Url"].ToString().Replace("~", ""));
                //sbList.Append("<%=ResolveClientUrl(" + "\"" + drDetailRow["Menu_Url"].ToString() + "\"" + ") %>");

                Control cl = new Control();
                if (drDetailRow["Menu_Url"].ToString().Contains("?"))
                {
                    sbList.Append(cl.ResolveClientUrl(drDetailRow["Menu_Url"].ToString()) + "&menu=" + iSpan.ToString() + "'");
                }
                else
                {
                    sbList.Append(cl.ResolveClientUrl(drDetailRow["Menu_Url"].ToString()) + "?menu=" + iSpan.ToString() + "'");
                }

                sbList.Append(" class='leftnav'>");
                sbList.Append(drDetailRow["Menu_Name"].ToString());
                sbList.Append("</a><br />");
            }

            iSpan = iSpan + 1;
            sbList.Append("</div>");
        }

        if (SiteMapPath1.Provider.CurrentNode == null)
        {
            dvLbMap.Style.Add("display", "");
            dvMapPath.Style.Add("display", "none");
        }
        else {
            dvLbMap.Style.Add("display", "none");
            dvMapPath.Style.Add("display", "");
        }

        //foreach (DataRow drRow in dt.Rows)
        //{
        //    sbList.Append("<h3 style='height:25px;'><a href='#'>");
        //    sbList.Append(drRow["Menu_Name"].ToString());
        //    sbList.Append("</a></h3>");
        //    sbList.Append("<div>");

        //    string sql = "select * from [CMS].[dbo].[CMS_SYS_MENU] where Parent_MenuId=" + drRow["Menu_ID"].ToString();
        //    SqlCommand detailcmd = new SqlCommand(sql, con);
        //    dtMenuList = new DataTable();
        //    SqlDataAdapter detailadapter = new SqlDataAdapter(detailcmd);
        //    detailadapter.Fill(dtMenuList);

        //    foreach (DataRow drDetailRow in dtMenuList.Rows)
        //    {
        //        sbList.Append("<a href='");
        //        sbList.Append(drDetailRow["Menu_Url"].ToString());
        //        sbList.Append("'>");
        //        sbList.Append(drDetailRow["Menu_Name"].ToString());
        //        sbList.Append("</a><br />");
        //    }
        //    sbList.Append("</div>");
        //}

        accordion.InnerHtml = sbList.ToString();
    }
Example #7
0
 /// <summary>
 /// Returns an url to this page that can be used on client side
 /// </summary>
 /// <param name="source"></param>
 /// <param name="htmlEncode">True to encode the url so can be used without problems inside an xhtml article</param>
 /// <returns></returns>
 public string GetClientUrl(Control source, bool htmlEncode)
 {
     string url = source.ResolveClientUrl(GetServerUrl(false));
     if (htmlEncode)
         url = HttpUtility.HtmlEncode(url);
     return url;
 }
 private string GetServiceUrl(Control containingControl, bool encodeSpaces) {
     string path = Path;
     if (String.IsNullOrEmpty(path)) {
         throw new InvalidOperationException(AtlasWeb.ServiceReference_PathCannotBeEmpty);
     }
     if (encodeSpaces) {
         path = containingControl.ResolveClientUrl(path);
     }
     else {
         path = containingControl.ResolveUrl(path);
     }
     return path;
 }
Example #9
0
		public void Methods_Deny_Unrestricted ()
		{
			Control c = new Control ();

			c.DataBind ();
			Assert.IsNull (c.FindControl ("mono"), "FindControl");

			Assert.IsFalse (c.HasControls (), "HasControls");
			c.RenderControl (writer);
			Assert.IsNotNull (c.ResolveUrl (String.Empty), "ResolveUrl");
			c.SetRenderMethodDelegate (new RenderMethod (SetRenderMethodDelegate));
#if NET_2_0
			c.ApplyStyleSheetSkin (page);
			Assert.IsNotNull (c.ResolveClientUrl (String.Empty), "ResolveClientUrl");
#endif
			c.Dispose ();
		}