本文整理汇总了C#中System.Web.UI.HtmlTextWriter.Close方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTextWriter.Close方法的具体用法?C# HtmlTextWriter.Close怎么用?C# HtmlTextWriter.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.HtmlTextWriter
的用法示例。
在下文中一共展示了HtmlTextWriter.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
//- #Render -//
/// <summary>
/// Removes viewstate, event validation and the ASP.NET form element from the page
/// </summary>
/// <param name="originalWriter">The original writer.</param>
protected override void Render(HtmlTextWriter originalWriter)
{
var stringWriter = new StringWriter(CultureInfo.CurrentCulture);
var htmlTextWriter = new HtmlTextWriter(stringWriter);
//+
base.Render(htmlTextWriter);
htmlTextWriter.Close();
//+
String data = stringWriter.GetStringBuilder().ToString();
String pattern = @"<div>([\r\n\s]*)<input type=""hidden"" name=""__VIEWSTATE"" id=""__VIEWSTATE"" value=""(?<viewstate>[+/=a-z0-9]+)"" />([\r\n\s]*)</div>";
data = Regex.Replace(data, pattern, String.Empty, RegexOptions.IgnoreCase);
pattern = @"<div>([\r\n\s]*)<input type=""hidden"" name=""__EVENTVALIDATION"" id=""__EVENTVALIDATION"" value=""(?<eventvalidation>[+/=a-z0-9]+)"" />([\r\n\s]*)</div>";
data = Regex.Replace(data, pattern, String.Empty, RegexOptions.IgnoreCase);
pattern = @"<form name=""ctl([\d]+)"" method=""post"" action="""" id=""ctl([\d]+)"">([\r\n\s]*)";
data = Regex.Replace(data, pattern, String.Empty, RegexOptions.IgnoreCase);
if (!EnableState)
{
pattern = @"<form name=""ctl([\d]+)"" method=""post"">([\r\n\s]*)";
data = Regex.Replace(data, pattern, String.Empty, RegexOptions.IgnoreCase);
}
pattern = @"([\r\n\s]*)</form>";
String replacement = String.Empty;
if (EnableState)
{
replacement = new StateArea().GetRenderData() + @"
</form>";
}
data = Regex.Replace(data, pattern, replacement, RegexOptions.IgnoreCase);
//+
originalWriter.Write(data);
}
示例2: Render
protected override void Render(HtmlTextWriter writer)
{
StringBuilder sb = new StringBuilder();
HtmlTextWriter tempWriter = new HtmlTextWriter(new StringWriter(sb));
base.Render(tempWriter);
tempWriter.Flush();
tempWriter.Close();
writer.Write(MyCompany.Data.Localizer.Replace("Pages", Path.GetFileName(Request.PhysicalPath), sb.ToString()));
}
示例3: ShowPropertyGrid
/// <summary>
/// Creates a simplistic Property Grid to display of an object
/// </summary>
/// <returns></returns>
public static string ShowPropertyGrid(object sourceObject)
{
if (sourceObject == null)
return "<hr/>No object passed.<hr/>";
StringBuilder sb = new StringBuilder();
using (StringWriter sw = new StringWriter(sb))
{
using (HtmlTextWriter hWriter = new HtmlTextWriter(sw))
{
hWriter.WriteBeginTag("table");
hWriter.WriteAttribute("border", "1");
hWriter.WriteAttribute("cellpadding", "5");
hWriter.WriteAttribute("class", "table table-bordered table-striped");
hWriter.Write(" style='border-collapse:collapse;'");
hWriter.Write(HtmlTextWriter.TagRightChar);
MemberInfo[] miT = sourceObject.GetType().FindMembers(MemberTypes.Field | MemberTypes.Property, BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly, null, null);
foreach (MemberInfo Field in miT)
{
string Name = Field.Name;
object Value = null;
if (Field.MemberType == MemberTypes.Field)
{
Value = ((FieldInfo)Field).GetValue(sourceObject);
continue;
}
else
if (Field.MemberType == MemberTypes.Property)
Value = ((PropertyInfo)Field).GetValue(sourceObject, null);
hWriter.WriteFullBeginTag("tr");
hWriter.WriteFullBeginTag("td");
hWriter.Write(Name);
hWriter.WriteEndTag("td");
hWriter.WriteLine();
hWriter.WriteFullBeginTag("td");
hWriter.WriteBeginTag("input");
hWriter.WriteAttribute("name", "Configuration." + Name);
hWriter.WriteAttribute("value", ReflectionUtils.TypedValueToString(Value));
hWriter.Write(" style='Width:400px' ");
hWriter.Write(HtmlTextWriter.TagRightChar);
hWriter.WriteEndTag("td");
hWriter.WriteLine();
hWriter.WriteEndTag("tr");
hWriter.WriteLine();
}
hWriter.WriteEndTag("table");
//string TableResult = sb.ToString();
hWriter.Close();
}
sw.Close();
}
return sb.ToString();
}
示例4: Render
public string Render(string newLine)
{
StringWriter sw = new StringWriter();
HtmlTextWriter writer = new HtmlTextWriter(sw, "");
writer.NewLine = newLine;
base.Render(writer);
writer.Flush();
writer.Close();
string result = sw.GetStringBuilder().ToString();
return result;
}
示例5: Render
/// <summary>
/// Override the base Render method.
/// </summary>
protected override void Render(HtmlTextWriter writer)
{
var htmlTableRemover = HtmlRemover ?? new HtmlRemover();
var sw = new StringWriter();
var hw = new HtmlTextWriter(sw);
base.Render(hw);
var html = htmlTableRemover.RemoveHtmlTableElements(sw.ToString());
hw.Close();
sw.Close();
writer.Write(html);
}
示例6: GetDesignTimeHtml
public override string GetDesignTimeHtml()
{
StringWriter sw = new StringWriter();
HtmlTextWriter writer = new HtmlTextWriter(sw);
writer.Write("<i>ProgressBar - no-Javascript fallback = {</i><a href='#'>");
ProgressBarBase control = (ProgressBarBase)Component;
if (!control.HasControls())
writer.Write("Check Upload Progress");
else
{
control.RenderChildControls(writer);
}
writer.Write("</a><i>}</i>");
writer.Close();
return sw.ToString();
}
示例7: GetDesignTimeHtml
/// <summary>
/// Returns the HTML to display in the VS IDE
/// </summary>
/// <returns>HTML string</returns>
public override string GetDesignTimeHtml()
{
//System.Diagnostics.Debugger.Break();
int numOfItems = _contextMenuInstance.ContextMenuItems.Count;
if (numOfItems == 0)
{
_contextMenuInstance.ContextMenuItems.Clear();
for(int i = 0; i < 5; i++)
{
ContextMenuItem item = new ContextMenuItem("Item", "");
_contextMenuInstance.ContextMenuItems.Add(item);
}
}
// Add the selected item
int selectedItemPos = 1;
ContextMenuItem selectedItem = new ContextMenuItem("Selected Item", "");
_contextMenuInstance.ContextMenuItems.AddAt(selectedItemPos, selectedItem);
// Pseudo-rendering
StringWriter swTemp = new StringWriter();
HtmlTextWriter writer = new HtmlTextWriter(swTemp);
_contextMenuInstance.RenderControl(writer);
writer.Close();
swTemp.Close();
// Modify the background color of the selected item
Table menu = (Table) (_contextMenuInstance.Controls[0]).Controls[0];
TableRow row = menu.Rows[selectedItemPos];
row.BackColor = _contextMenuInstance.RolloverColor;
StringWriter sw = new StringWriter();
writer.InnerWriter = sw;
menu.RenderControl(writer);
if (numOfItems == 0)
_contextMenuInstance.ContextMenuItems.Clear();
else
_contextMenuInstance.ContextMenuItems.RemoveAt(selectedItemPos);
return sw.ToString();
}
示例8: ToHtml
public string ToHtml()
{
System.IO.StringWriter writer = new StringWriter();
HtmlTextWriter htmlTextWriter = new HtmlTextWriter(writer);
this.Render(htmlTextWriter);
string result = htmlTextWriter.InnerWriter.ToString();
htmlTextWriter.Close();
string userDefineFoot = @"<tr {2}>
<td colspan=""{0}"">
{1}
</td>
</tr>";
return string.Format(userDefineFoot, ColSpan, result, FootClass == string.Empty ? string.Empty : string.Format( @"class=""{0}""", this.FootClass));
}
示例9: GetCallbackResult
public string GetCallbackResult()
{
string[] str = new string[] { "11", "22", "33", "44" };
ListItem item = null;
this.drpList1.Items.Clear();
foreach (string tmp in str)
{
item = new ListItem(tmp, tmp);
this.drpList1.Items.Add(item);
}
StringWriter writer1 = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
HtmlTextWriter writer2 = new HtmlTextWriter(writer1);
this.drpList1.RenderControl(writer2);
writer2.Flush();
writer2.Close();
return writer1.ToString();
}
示例10: GetDesignTimeHtml
public override string GetDesignTimeHtml()
{
DynamicImage control = (DynamicImage) Component;
StringWriter textWriter = new StringWriter();
HtmlTextWriter writer = new HtmlTextWriter(textWriter);
control.RenderControl(writer);
CompositionImage image = control.Composition.GetCompositionImage();
string designTimeImageUrl = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + "." + image.Properties.FileExtension);
using (FileStream fileStream = File.OpenWrite(designTimeImageUrl))
{
image.Properties.GetEncoder().Save(fileStream);
}
string html = textWriter.ToString().Replace("src=\"", "src=\"file:///").Replace("src='", "src='file:///");
writer.Close();
textWriter.Close();
return html;
}
示例11: RenderToMessage
public static string RenderToMessage(System.Web.UI.UserControl ctrControl)
{
System.Text.StringBuilder sbuBuilder;
System.IO.StringWriter wriWriter;
System.Web.UI.HtmlTextWriter htwWriter;
sbuBuilder = new System.Text.StringBuilder();
sbuBuilder.Append("<html>");
sbuBuilder.Append("<body>");
wriWriter = new System.IO.StringWriter(sbuBuilder);
htwWriter = new System.Web.UI.HtmlTextWriter(wriWriter);
ctrControl.RenderControl(htwWriter);
htwWriter.Close();
wriWriter.Close();
sbuBuilder.Append("</body>");
sbuBuilder.Append("</html>");
return sbuBuilder.ToString();
}
示例12: Render
protected override void Render (HtmlTextWriter writer)
{
if (!renderDisabled)
{
if (renderCacheContent == null)
{
// cache expired
using (var stringWriter = new System.IO.StringWriter ())
using (var htmlWriter = new HtmlTextWriter (stringWriter))
{
// render the current page content to our temp writer
base.Render (htmlWriter);
// htmlWriter.Flush();
htmlWriter.Close ();
// get the content
renderCacheContent = stringWriter.ToString ();
}
// NOTE: For testing purposes
// renderCacheContent = string.Concat (renderCacheContent, "<p>" + DateTime.Now.ToShortTimeString () + "</p>");
// NOTE: Set render cache only in non-edit mode - this give editors
// somethat increased performance and ensures that common users see only allowed content
if (!IsEditable)
{
var settings = new EmployeeSettings (this);
CacheHelper.Set<string> (renderCacheContent, DataCacheKey, settings.DataCacheTime);
}
}
// write the new html to the page
writer.Write (renderCacheContent);
}
}
示例13: RssToHtml
public void RssToHtml(string input, string output)
{
// write as UTF-8
HtmlTextWriter writer = new HtmlTextWriter(new StreamWriter(output), " ");
XmlTextReader reader = new XmlTextReader(input)
{
XmlResolver = null,
WhitespaceHandling = WhitespaceHandling.None
};
reader.MoveToContent();
if (reader.Name == "rss")
{
writer.RenderBeginTag(HtmlTextWriterTag.Html);
while (reader.Read() &&
reader.NodeType != XmlNodeType.EndElement)
{
switch (reader.LocalName)
{
case "channel":
ChannelToHtml(reader, writer);
break;
case "item":
//ItemToHtml(reader, writer);
break;
default: // ignore image and textinput.
break;
}
}
writer.RenderEndTag();
}
reader.Close();
writer.Close();
}
示例14: ToExcelE
public static void ToExcelE(System.Web.UI.WebControls.DataGrid DataGrid2Excel, string FileName)
{
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" + FileName + ".xls"); //filename=Report.xls
HttpContext.Current.Response.Charset = "GB2312"; //UTF-8
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
DataGrid2Excel.RenderControl(hw); //Get the HTML for the control.
hw.Flush();
hw.Close();
HttpContext.Current.Response.Write(tw.ToString()); //Write the HTML back to the browser.
HttpContext.Current.Response.End();
}
示例15: BuildReport
//.........这里部分代码省略.........
html_writer.RenderEndTag(); // </td>
html_writer.AddAttribute(HtmlTextWriterAttribute.Class, "results");
html_writer.RenderBeginTag(HtmlTextWriterTag.Th); // <td class="...">
html_writer.Write("Value");
html_writer.RenderEndTag(); // </td>
html_writer.AddAttribute(HtmlTextWriterAttribute.Class, "results");
html_writer.RenderBeginTag(HtmlTextWriterTag.Th); // <td class="...">
html_writer.Write("Percentage");
html_writer.RenderEndTag(); html_writer.RenderEndTag(); // </th></tr>
html_writer.RenderBeginTag(HtmlTextWriterTag.Tr); // <tr>
html_writer.AddAttribute(HtmlTextWriterAttribute.Class, "results_description");
html_writer.RenderBeginTag(HtmlTextWriterTag.Td); // <td class="...">
html_writer.RenderBeginTag(HtmlTextWriterTag.Strong); html_writer.Write("Mean:"); html_writer.RenderEndTag();
html_writer.RenderEndTag(); // </td>
html_writer.AddAttribute(HtmlTextWriterAttribute.Class, "results_value");
html_writer.RenderBeginTag(HtmlTextWriterTag.Td); // <td class="...">
string temp = _dataset.JitterStats.Mean + " ns"; html_writer.Write(temp);
html_writer.RenderEndTag(); // </td>
html_writer.AddAttribute(HtmlTextWriterAttribute.Class, "results_value");
html_writer.RenderBeginTag(HtmlTextWriterTag.Td); // <td class="...">
html_writer.Write(" ");
html_writer.RenderEndTag(); html_writer.RenderEndTag(); // </td></tr>
html_writer.RenderBeginTag(HtmlTextWriterTag.Tr); // <tr>
html_writer.AddAttribute(HtmlTextWriterAttribute.Class, "results_description");
html_writer.RenderBeginTag(HtmlTextWriterTag.Td); // <td class="...">
html_writer.RenderBeginTag(HtmlTextWriterTag.Strong); html_writer.Write("Minimum:"); html_writer.RenderEndTag();
html_writer.RenderEndTag(); // </td>
html_writer.AddAttribute(HtmlTextWriterAttribute.Class, "results_value");
html_writer.RenderBeginTag(HtmlTextWriterTag.Td); // <td class="...">
temp = _dataset.JitterStats.Minimum + " ns"; html_writer.Write(temp);
html_writer.RenderEndTag(); // </td>
html_writer.AddAttribute(HtmlTextWriterAttribute.Class, "results_value");
html_writer.RenderBeginTag(HtmlTextWriterTag.Td); // <td class="...">
temp = Math.Round((_dataset.JitterStats.Mean - _dataset.JitterStats.Minimum) / _dataset.JitterStats.Mean * 100, 3).ToString(); html_writer.Write(temp + "%");
html_writer.RenderEndTag(); html_writer.RenderEndTag(); // </td></tr>
html_writer.RenderBeginTag(HtmlTextWriterTag.Tr); // <tr>
html_writer.AddAttribute(HtmlTextWriterAttribute.Class, "results_description");
html_writer.RenderBeginTag(HtmlTextWriterTag.Td); // <td class="...">
html_writer.RenderBeginTag(HtmlTextWriterTag.Strong); html_writer.Write("Maximum:"); html_writer.RenderEndTag();
html_writer.RenderEndTag(); // </td>
html_writer.AddAttribute(HtmlTextWriterAttribute.Class, "results_value");
html_writer.RenderBeginTag(HtmlTextWriterTag.Td); // <td class="...">
temp = _dataset.JitterStats.Maximum + " ns"; html_writer.Write(temp);
html_writer.RenderEndTag(); // </td>
html_writer.AddAttribute(HtmlTextWriterAttribute.Class, "results_value");
html_writer.RenderBeginTag(HtmlTextWriterTag.Td); // <td class="...">
temp = Math.Round((_dataset.JitterStats.Maximum - _dataset.JitterStats.Mean) / _dataset.JitterStats.Mean * 100, 3).ToString(); html_writer.Write(temp + "%");
html_writer.RenderEndTag(); html_writer.RenderEndTag(); // </td></tr>
html_writer.RenderBeginTag(HtmlTextWriterTag.Tr); // <tr>
html_writer.AddAttribute(HtmlTextWriterAttribute.Class, "results_description");
html_writer.RenderBeginTag(HtmlTextWriterTag.Td); // <td class="...">
html_writer.RenderBeginTag(HtmlTextWriterTag.Strong); html_writer.Write("Standard Deviation:"); html_writer.RenderEndTag();
html_writer.RenderEndTag(); // </td>
html_writer.AddAttribute(HtmlTextWriterAttribute.Class, "results_value");
html_writer.RenderBeginTag(HtmlTextWriterTag.Td); // <td class="...">
html_writer.Write(_dataset.JitterStats.StandardDeviation + " ns");
html_writer.RenderEndTag(); // </td>
html_writer.AddAttribute(HtmlTextWriterAttribute.Class, "results_value");
html_writer.RenderBeginTag(HtmlTextWriterTag.Td); // <td class="...">
temp = Math.Round(_dataset.JitterStats.StandardDeviation / _dataset.JitterStats.Mean * 100, 6).ToString(); html_writer.Write(temp + "%");
html_writer.RenderEndTag(); html_writer.RenderEndTag(); // </td></tr>
html_writer.RenderEndTag(); // </table>
// ----------------------------------------------------------------
// Jitter Graph
// ----------------------------------------------------------------
html_writer.RenderBeginTag(HtmlTextWriterTag.H3); html_writer.Write("Jitter Graph"); html_writer.RenderEndTag();
// Use relative file naming for chart filename
FileInfo chart_file_info = new FileInfo(chart_filename);
html_writer.AddAttribute(HtmlTextWriterAttribute.Src, chart_file_info.Name);
html_writer.RenderBeginTag(HtmlTextWriterTag.Img); // <img src="..."
html_writer.RenderEndTag(); // />
// ----------------------------------------------------------------
// Process Log
// ----------------------------------------------------------------
html_writer.RenderBeginTag(HtmlTextWriterTag.H2); html_writer.Write("Process Log"); html_writer.RenderEndTag();
html_writer.AddAttribute(HtmlTextWriterAttribute.Class, "log");
html_writer.RenderBeginTag(HtmlTextWriterTag.P); // <p style="...">
html_writer.WriteLine("");
for (int i = 0; i < _process_log.Count; i++)
{
html_writer.WriteLine(_process_log[i]); html_writer.WriteBreak();
}
html_writer.RenderEndTag(); // </p>
html_writer.RenderEndTag(); // </body>
html_writer.RenderEndTag(); // </html>
html_writer.Close();
// Show the HTML file
//System.Diagnostics.Process.Start("file:///" + html_filename);
return html_filename;
}