Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using System.Web.Mvc.Html;
- using System.Web.Routing;
- using System.Web.Security;
- public static class RouteValueHelper {
- public static RouteValueDictionary AnonymousObjectToHtmlAttributes(object htmlAttributes) {
- if(htmlAttributes == null) {
- return null;
- }
- RouteValueDictionary routeValueDictionaries = new RouteValueDictionary();
- foreach(PropertyDescriptor property in TypeDescriptor.GetProperties(htmlAttributes)) {
- routeValueDictionaries.Add(property.Name,property.GetValue(htmlAttributes));
- }
- return routeValueDictionaries;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment