当前位置: 首页>>代码示例>>C#>>正文


C# HtmlGenericControl.Dispose方法代码示例

本文整理汇总了C#中System.Web.UI.HtmlControls.HtmlGenericControl.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlGenericControl.Dispose方法的具体用法?C# HtmlGenericControl.Dispose怎么用?C# HtmlGenericControl.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.HtmlControls.HtmlGenericControl的用法示例。


在下文中一共展示了HtmlGenericControl.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GoogleMap

        private static MvcHtmlString GoogleMap(HtmlHelper helper, string id, Models.Map map, bool editor)
        {
            StringBuilder sbControlHtml = new StringBuilder();
            using (StringWriter stringWriter = new StringWriter())
            {
                using (HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter))
                {
                    //Generate container div control
                    HtmlGenericControl divWrapperControl = new HtmlGenericControl("div");
                    HtmlGenericControl divMapControl = new HtmlGenericControl("div");
                    divMapControl.Attributes.Add("class", "map-container");
                    divMapControl.Attributes.Add("id", string.Format("map-{0}", id));
                    if (map.height > 0 || map.width > 0)
                    {
                        string widthStyle = "width:{0}px;";
                        if (map.width > 0)
                        {
                            widthStyle = string.Format(widthStyle, map.width);
                        }
                        else
                        {
                            widthStyle = string.Empty;
                        }

                        string heightStyle = "height:{0}px;";
                        if (map.height > 0)
                        {
                            heightStyle = string.Format(heightStyle, map.height);
                        }
                        else
                        {
                            heightStyle = string.Empty;
                        }

                        divMapControl.Attributes.Add("style", string.Concat(widthStyle, heightStyle));
                    }

                    divWrapperControl.Controls.Add(divMapControl);

                    //value input control
                    HtmlInputHidden hidden = new HtmlInputHidden();
                    HtmlInputHidden hiddenValueControl = new HtmlInputHidden();
                    hiddenValueControl.ID = id;
                    divWrapperControl.Controls.Add(hiddenValueControl);

                    HtmlGenericControl scriptControl = new HtmlGenericControl("script");
                    scriptControl.Attributes.Add("type", "text/javascript");
                    scriptControl.InnerHtml = string.Format(@"$(document).ready(function(){{
                                                    $('#map-{0}').GoogleMapEditor($.extend({{}},{1},{{dataChange:function(sender, data){{ $(sender.container).next().next().val(data); }}}}));}});", id, map.ToJsonString());
                    divWrapperControl.Controls.Add(scriptControl);
                    divWrapperControl.RenderControl(htmlWriter);
                    sbControlHtml.Append(stringWriter.ToString());
                    divWrapperControl.Dispose();
                }
            }
            return new MvcHtmlString(sbControlHtml.ToString());
        }
开发者ID:landsurveyorsunited,项目名称:MVC-GoogleMaps,代码行数:57,代码来源:HtmlHelpers.cs

示例2: GetMarkerEditForm

        public HttpResponseMessage GetMarkerEditForm(string filename, bool richtext = false)
        {
            string result = Common.GetResourceText(filename);
            StringBuilder sbFiles = new StringBuilder();

            string folderPath = "/Umbraco/Images/MapPins/";
            if (Directory.Exists(HttpContext.Current.Server.MapPath(folderPath)))
            {
                foreach (string file in Directory.GetFiles(HttpContext.Current.Server.MapPath(folderPath)))
                {
                    using (StringWriter stringWriter = new StringWriter())
                    {
                        using (HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter))
                        {
                            HtmlGenericControl optionHtml = new HtmlGenericControl("option");
                            optionHtml.Attributes.Add("value", string.Concat(folderPath, Path.GetFileName(file)));
                            optionHtml.InnerText = Path.GetFileName(file);
                            optionHtml.RenderControl(htmlWriter);
                            sbFiles.Append(stringWriter.ToString());
                            optionHtml.Dispose();
                        }
                    }
                }
            }

            return new HttpResponseMessage()
            {
                Content = new StringContent(string.Format(result, sbFiles.ToString(), richtext ? "richtext-fix" : string.Empty), System.Text.Encoding.UTF8, "application/html")
            };
        }
开发者ID:landsurveyorsunited,项目名称:Umbraco-GoogleMap-Editor,代码行数:30,代码来源:ResourceController.cs


注:本文中的System.Web.UI.HtmlControls.HtmlGenericControl.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。