本文整理汇总了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());
}
示例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")
};
}