Пример #1
0
        /// <summary>
        /// HTMLs the control from string.
        /// </summary>
        /// <param name="html">The HTML.</param>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        internal static HtmlControl HtmlControlFromString(string html, Type type)
        {
            if (!typeof(HtmlControl).IsAssignableFrom(type))
            {
                throw new InvalidCastException("The target type is not a HtmlControlType");
            }

            html = AddRunAtServer(html, (Activator.CreateInstance(type) as HtmlControl).TagName);

            if (type.IsAssignableFrom(typeof(HtmlSelect)))
            {
                html = CorrectAttributes(html);
            }

            Control o = HtmlControlConverterHelper.Parse(html);;

            if (o.GetType() == type)
            {
                return(o as HtmlControl);
            }
            else
            {
                foreach (Control con in o.Controls)
                {
                    if (con.GetType() == type)
                    {
                        return(con as HtmlControl);
                    }
                }
            }

            return(null);
        }
Пример #2
0
        /// <summary>
        /// Parses the specified control string.
        /// </summary>
        /// <param name="controlString">The control string.</param>
        /// <returns></returns>
        internal static Control Parse(string controlString)
        {
            HtmlControlConverterHelper control = new HtmlControlConverterHelper();

#if (NET20)
            control.AppRelativeVirtualPath = "~";
#endif

            return(control.ParseControl(controlString));
        }
Пример #3
0
        /// <summary>
        /// Parses the specified control string.
        /// </summary>
        /// <param name="controlString">The control string.</param>
        /// <returns></returns>
        internal static Control Parse(string controlString)
        {
            HtmlControlConverterHelper control = new HtmlControlConverterHelper();
            #if(NET20)
            control.AppRelativeVirtualPath = "~";
            #endif

            return control.ParseControl(controlString);
        }