當前位置: 首頁>>代碼示例>>C#>>正文


C# Control.GetRouteUrl方法代碼示例

本文整理匯總了C#中System.Web.UI.Control.GetRouteUrl方法的典型用法代碼示例。如果您正苦於以下問題:C# Control.GetRouteUrl方法的具體用法?C# Control.GetRouteUrl怎麽用?C# Control.GetRouteUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Web.UI.Control的用法示例。


在下文中一共展示了Control.GetRouteUrl方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetRouteUrl

        // Format will be <%$ ExpPrefix: RouteName = <name>, Key=Value, Key2=Value2 %>
        public static string GetRouteUrl(Control control, string expression) {
            if (control == null) {
                throw new ArgumentNullException("control");
            }

            string routeName = null;
            RouteValueDictionary routeParams = new RouteValueDictionary();
            if (TryParseRouteExpression(expression, routeParams, out routeName)) {
                return control.GetRouteUrl(routeName, routeParams);
            }
            else {
                throw new InvalidOperationException(SR.GetString(SR.RouteUrlExpression_InvalidExpression));
            }
        }
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:15,代碼來源:RouteUrlExpressionBuilder.cs

示例2: GetRouteUrl

 public static string GetRouteUrl(Control control, string expression)
 {
     if (control == null)
     {
         throw new ArgumentNullException("control");
     }
     string routeName = null;
     RouteValueDictionary routeValues = new RouteValueDictionary();
     if (!TryParseRouteExpression(expression, routeValues, out routeName))
     {
         throw new InvalidOperationException(System.Web.SR.GetString("RouteUrlExpression_InvalidExpression"));
     }
     return control.GetRouteUrl(routeName, routeValues);
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:14,代碼來源:RouteUrlExpressionBuilder.cs

示例3: GetRouteUrl_String_RouteValueDictionary_Load

		public static void GetRouteUrl_String_RouteValueDictionary_Load (Page p)
		{
			RouteTable.Routes.Clear ();

			var ctl = new Control ();
			var rvd = new RouteValueDictionary {
				{"foo", "one"},
				{"bar", "two"}
			};
			string path;
			AssertExtensions.Throws<ArgumentException> (() => {
				path = ctl.GetRouteUrl ("myroute", rvd);
			}, "#A1");

			RouteTable.Routes.Add (new Route ("{foo}-{bar}", new PageRouteHandler ("~/default.aspx")));
			RouteTable.Routes.Add ("myroute", new Route ("{bar}-{foo}", new PageRouteHandler ("~/default.aspx")));
			path = ctl.GetRouteUrl ("myroute", rvd);
			Assert.IsNotNull (path, "#A2-1");
			Assert.AreEqual ("/NunitWeb/two-one", path, "#A2-2");

			path = ctl.GetRouteUrl ("myroute", (RouteValueDictionary) null);
			Assert.IsNull (path, "#A3-1");

			path = ctl.GetRouteUrl (null, (RouteValueDictionary) null);
			Assert.IsNull (path, "#A3-2");

			path = ctl.GetRouteUrl (String.Empty, (RouteValueDictionary) null);
			Assert.IsNull (path, "#A3-3");
		}
開發者ID:carrie901,項目名稱:mono,代碼行數:29,代碼來源:ControlTest.cs

示例4: GetRouteUrl_String_Object_Load

		public static void GetRouteUrl_String_Object_Load (Page p)
		{
			RouteTable.Routes.Clear ();

			var ctl = new Control ();
			object obj = new { foo = "one", bar = "two" };
			string path;
			AssertExtensions.Throws<ArgumentException> (() => {
				path = ctl.GetRouteUrl ("myroute1", obj);
			}, "#A1");

			RouteTable.Routes.Add (new Route ("{foo}-{bar}", new PageRouteHandler ("~/default.aspx")));
			RouteTable.Routes.Add ("myroute1", new Route ("{bar}-{foo}", new PageRouteHandler ("~/default.aspx")));
			path = ctl.GetRouteUrl ("myroute1", obj);
			Assert.IsNotNull (path, "#A2-1");
			Assert.AreEqual ("/NunitWeb/two-one", path, "#A2-2");

			path = ctl.GetRouteUrl ("myroute1", (object) null);
			Assert.IsNull (path, "#A3");
		}
開發者ID:carrie901,項目名稱:mono,代碼行數:20,代碼來源:ControlTest.cs

示例5: GetRouteUrl_RouteValueDictionary_Load

		public static void GetRouteUrl_RouteValueDictionary_Load (Page p)
		{
			RouteTable.Routes.Clear ();

			var ctl = new Control ();
			var rvd = new RouteValueDictionary {
				{"foo", "one"},
				{"bar", "two"}
			};
			string path = ctl.GetRouteUrl (rvd);
			Assert.IsNull (path, "#A1");

			RouteTable.Routes.Add (new Route ("{foo}-{bar}", new PageRouteHandler ("~/default.aspx")));
			path = ctl.GetRouteUrl (rvd);
			Assert.IsNotNull (path, "#A2-1");
			Assert.AreEqual ("/NunitWeb/one-two", path, "#A2-2");

			path = ctl.GetRouteUrl ((RouteValueDictionary) null);
			Assert.IsNull (path, "#A3");
		}
開發者ID:carrie901,項目名稱:mono,代碼行數:20,代碼來源:ControlTest.cs

示例6: GetRouteUrl_Object_Load

		public static void GetRouteUrl_Object_Load (Page p)
		{
			RouteTable.Routes.Clear ();

			var ctl = new Control ();
			object obj = new { foo = "one", bar = "two" };
			string path = ctl.GetRouteUrl (obj);
			Assert.IsNull (path, "#A1");

			RouteTable.Routes.Add (new Route ("{foo}-{bar}", new PageRouteHandler ("~/default.aspx")));
			path = ctl.GetRouteUrl (obj);
			Assert.IsNotNull (path, "#A2-1");
			Assert.AreEqual ("/NunitWeb/one-two", path, "#A2-2");

			path = ctl.GetRouteUrl ((object)null);
			Assert.IsNull (path, "#A3");
		}
開發者ID:carrie901,項目名稱:mono,代碼行數:17,代碼來源:ControlTest.cs

示例7: GetRouteUrl

		public static string GetRouteUrl (Control control, string expression)
		{
			if (control == null)
				throw new ArgumentNullException ("control");
			
			string routeName;
			var rvd = new RouteValueDictionary ();
			
			if (!TryParseRouteExpression (expression, rvd, out routeName))
				throw new InvalidOperationException ("Invalid expression, RouteUrlExpressionBuilder expects a string with format: RouteName=route,Key1=Value1,Key2=Value2");

			return control.GetRouteUrl (routeName, rvd);
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:13,代碼來源:RouteUrlExpressionBuilder.cs


注:本文中的System.Web.UI.Control.GetRouteUrl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。