本文整理汇总了C#中HtmlTextWriter.Flush方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTextWriter.Flush方法的具体用法?C# HtmlTextWriter.Flush怎么用?C# HtmlTextWriter.Flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlTextWriter
的用法示例。
在下文中一共展示了HtmlTextWriter.Flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
//protected override object LoadPageStateFromPersistenceMedium()
//{
// try
// {
// if (Session.Count != 0)
// {
// string viewState = (string)Session[Session.SessionID];
// byte[] bytes = Convert.FromBase64String(viewState);
// bytes = Compressor.Decompress(bytes);
// LosFormatter formatter = new LosFormatter();
// return formatter.Deserialize(Convert.ToBase64String(bytes));
// }
// return base.LoadPageStateFromPersistenceMedium();
// //return new object();
// }
// catch (Exception ex)
// {
// throw ex;
// }
//}
//protected override void SavePageStateToPersistenceMedium(object state)
//{
// try
// {
// if (Session.Count != 0)
// {
// LosFormatter formatter = new LosFormatter();
// StringWriter writer = new StringWriter();
// formatter.Serialize(writer, state);
// string viewStateString = writer.ToString();
// byte[] bytes = Convert.FromBase64String(viewStateString);
// bytes = Compressor.Compress(bytes);
// Session[Session.SessionID] = Convert.ToBase64String(bytes);
// }
// else
// base.SavePageStateToPersistenceMedium(state);
// }
// catch (Exception ex)
// {
// throw ex;
// }
//}
protected override void Render(HtmlTextWriter writer)
{
MemoryStream memoryStream = new MemoryStream();
try
{
using (StreamWriter streamWriter = new StreamWriter(memoryStream))
{
var textWriter = new HtmlTextWriter(streamWriter);
base.Render(textWriter);
textWriter.Flush();
memoryStream.Position = 0;
using (StreamReader reader = new StreamReader(memoryStream))
{
var text = reader.ReadToEnd();
writer.Write(text);
reader.Close();
}
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
memoryStream.Dispose();
}
}
示例2: GetHtmlFromControl
public static string GetHtmlFromControl(this System.Web.UI.Control control)
{
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
control.RenderControl(htw);
htw.Flush();
return sw.ToString();
}
示例3: getHTML
private string getHTML(Panel Pnl)
{
StringBuilder sb = new StringBuilder();
StringWriter textwriter = new StringWriter(sb);
HtmlTextWriter htmlwriter = new HtmlTextWriter(textwriter);
Pnl.RenderControl(htmlwriter);
htmlwriter.Flush();
textwriter.Flush();
htmlwriter.Dispose();
textwriter.Dispose();
return sb.ToString();
}
示例4: ShowUpdateForm
/// <summary>
/// Generates a SPARQL Update Form
/// </summary>
/// <param name="context">HTTP Context</param>
protected virtual void ShowUpdateForm(HttpContext context)
{
//Set Content Type
context.Response.Clear();
context.Response.ContentType = "text/html";
//Get a HTML Text Writer
HtmlTextWriter output = new HtmlTextWriter(new StreamWriter(context.Response.OutputStream));
//Page Header
output.Write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
output.RenderBeginTag(HtmlTextWriterTag.Html);
output.RenderBeginTag(HtmlTextWriterTag.Head);
output.RenderBeginTag(HtmlTextWriterTag.Title);
output.WriteEncodedText("SPARQL Update Interface");
output.RenderEndTag();
//Add Stylesheet
if (!this._config.Stylesheet.Equals(String.Empty))
{
output.AddAttribute(HtmlTextWriterAttribute.Href, this._config.Stylesheet);
output.AddAttribute(HtmlTextWriterAttribute.Type, "text/css");
output.AddAttribute(HtmlTextWriterAttribute.Rel, "stylesheet");
output.RenderBeginTag(HtmlTextWriterTag.Link);
output.RenderEndTag();
}
output.RenderEndTag();
//Header Text
output.RenderBeginTag(HtmlTextWriterTag.Body);
output.RenderBeginTag(HtmlTextWriterTag.H3);
output.WriteEncodedText("SPARQL Update Interface");
output.RenderEndTag();
//Query Form
output.AddAttribute(HtmlTextWriterAttribute.Name, "sparqlUpdate");
output.AddAttribute("method", "get");
output.AddAttribute("action", context.Request.Path);
output.RenderBeginTag(HtmlTextWriterTag.Form);
if (!this._config.IntroductionText.Equals(String.Empty))
{
output.RenderBeginTag(HtmlTextWriterTag.P);
output.Write(this._config.IntroductionText);
output.RenderEndTag();
}
output.WriteEncodedText("Update");
output.WriteBreak();
output.AddAttribute(HtmlTextWriterAttribute.Name, "update");
output.AddAttribute(HtmlTextWriterAttribute.Rows, "15");
output.AddAttribute(HtmlTextWriterAttribute.Cols, "100");
output.RenderBeginTag(HtmlTextWriterTag.Textarea);
output.WriteEncodedText(this._config.DefaultUpdate);
output.RenderEndTag();
output.WriteBreak();
//output.WriteEncodedText("Default Graph URI: ");
//output.AddAttribute(HtmlTextWriterAttribute.Name, "default-graph-uri");
//output.AddAttribute(HtmlTextWriterAttribute.Type, "text");
//output.AddAttribute(HtmlTextWriterAttribute.Size, "100");
//output.AddAttribute(HtmlTextWriterAttribute.Value, this._config.DefaultGraphURI);
//output.RenderBeginTag(HtmlTextWriterTag.Input);
//output.RenderEndTag();
//output.WriteBreak();
output.AddAttribute(HtmlTextWriterAttribute.Type, "submit");
output.AddAttribute(HtmlTextWriterAttribute.Value, "Perform Update");
output.RenderBeginTag(HtmlTextWriterTag.Input);
output.RenderEndTag();
output.RenderEndTag(); //End Form
//End of Page
output.RenderEndTag(); //End Body
output.RenderEndTag(); //End Html
output.Flush();
}
示例5: GetDesignTimeHtml
/// <summary>
/// The design time generated HTML for the control.
/// </summary>
/// <returns>A string containing the HTML rendering.</returns>
public override string GetDesignTimeHtml()
{
// Extremely simple design time rendering!
// will work on something better sooner or later.
// This acts as a placeholder.
Web.PlotSurface2D plot = (Web.PlotSurface2D)Component;
int xs = Convert.ToInt32(plot.Width.Value);
if ( xs < 1 ) return "";
int ys = Convert.ToInt32(plot.Height.Value);
if ( ys < 1 ) return "";
StringWriter sw = new StringWriter();
HtmlTextWriter output= new HtmlTextWriter(sw);
output.AddAttribute("border",plot.BorderWidth.ToString());
output.AddAttribute("borderColor",plot.BorderColor.ToKnownColor().ToString());
output.AddAttribute("cellSpacing","0");
output.AddAttribute("cellPadding","0");
output.AddAttribute("width",xs.ToString());
output.RenderBeginTag("table ");
output.RenderBeginTag("tr");
output.AddAttribute("vAlign","center");
output.AddAttribute("align","middle");
output.AddAttribute("height",ys.ToString());
output.RenderBeginTag("td");
output.RenderBeginTag("P");
output.Write("PlotSurface2D:" + plot.Title);
output.RenderEndTag();
output.RenderEndTag();
output.RenderEndTag();
output.RenderEndTag();
output.Flush();
return sw.ToString();
}
示例6: renderGrid
private void renderGrid(GridView gridView1)
{
using (StringWriter StringWriter1 = new StringWriter())
{
HtmlTextWriter htw1 = new HtmlTextWriter(StringWriter1);
gridView1.RenderControl(htw1);
htw1.Flush();
result = StringWriter1.ToString();
}
}
示例7: RenderControl
protected string RenderControl(Control control)
{
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
control.RenderControl(htw);
htw.Flush();
return sw.ToString();
}
示例8: GetCallbackResult
protected virtual string GetCallbackResult() {
StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture);
//
HtmlTextWriter writer = new HtmlTextWriter(stringWriter);
IStateFormatter2 formatter = Page.CreateStateFormatter();
RenderTableContents(writer);
writer.Flush();
writer.Close();
object dataKeyState = OrderedDictionaryStateHelper.SaveViewState(KeyTable);
string dataKeyString = formatter.Serialize(dataKeyState, Purpose.WebForms_DetailsView_KeyTable);
// this should return the html that goes in the panel, plus the new page info.
return Convert.ToString(PageIndex, CultureInfo.InvariantCulture) + "|" + dataKeyString + "|" + stringWriter.ToString();
}
示例9: Render
/// <summary>
/// Render this control as an HTML stream.
/// </summary>
/// <param name="output">The HTML writer to write out to.</param>
protected override void Render(HtmlTextWriter output)
{
// first of all render the bitmap;
System.Drawing.Bitmap b = new System.Drawing.Bitmap( (int)this.Width.Value, (int)this.Height.Value );
if (backColor_!=null)
{
Graphics g = Graphics.FromImage( b );
g.FillRectangle( (new Pen( (Color)this.backColor_)).Brush,0,0,b.Width,b.Height );
}
ps_.Draw( Graphics.FromImage(b), new System.Drawing.Rectangle(0,0,b.Width,b.Height) );
// then store in context memory.
Context.Session[prefix()+"PNG"] = b;
// now render html.
if (this.BorderStyle == BorderStyle.None)
{
output.AddAttribute("border","0");
}
else
{
output.AddAttribute("border",this.BorderWidth.ToString());
output.AddAttribute("borderColor",this.BorderColor.ToKnownColor().ToString());
}
output.AddAttribute("cellSpacing","0");
output.AddAttribute("cellPadding","0");
output.RenderBeginTag("table");
output.RenderBeginTag("tr");
output.AddAttribute("vAlign","center");
output.AddAttribute("align","middle");
output.RenderBeginTag("td");
output.RenderBeginTag("P");
output.AddAttribute("src",this.plotUrl);
output.AddAttribute("alt",this.ToolTip);
output.RenderBeginTag("img");
output.RenderEndTag();
output.RenderEndTag();
output.RenderEndTag();
output.RenderEndTag();
output.RenderEndTag();
output.Flush();
}
示例10: SavePageASHtml
//public bool CreateWebPage()
//{
// HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://opi.yahoo.com/online");
// request.Timeout = 9 * 1000; // set request timeout = 9 second. if yahoo api failed to respond in 9 second request would get timed out.
// request.Method = "Post"; // we will post the data using post method
// string postData = "u=" + TextBox1.Text + "&m=s&t=8";
// // data to be posted using HttpWebrequest post method
// // we will post parameter u , m and t
// // Convert this string into stream of bytes
// byte[] arrPostDAta = System.Text.Encoding.GetEncoding(1252).GetBytes(postData);
// // set request content length = post data length
// request.ContentLength = arrPostDAta.Length;
// System.IO.Stream strmPostData = request.GetRequestStream();
// // get request stream
// // write post data to stream of request
// strmPostData.Write(arrPostDAta, 0, arrPostDAta.Length);
// strmPostData.Close();
// // upload post data and Get Response from server
// HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// StreamReader reader = new StreamReader(response.GetResponseStream());
// Label1.Text = reader.ReadToEnd();
// reader.Close();
// response.Close();
//}
public void SavePageASHtml(string location, Page pge)
{
StringWriter stringWriter = new StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
pge.RenderControl(htmlWriter);
htmlWriter.Flush();
FileStream fileStream = new FileStream(location, FileMode.Create);
string siteString = stringWriter.ToString();
byte[] byteArray = Encoding.UTF8.GetBytes(siteString);
fileStream.Write(byteArray, 0, byteArray.Length);
fileStream.Close();
//Response.End();
//Response.Redirect("~/PriceList.aspx");
}
示例11: GetCallbackResult
protected virtual string GetCallbackResult() {
StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture);
//
HtmlTextWriter writer = new HtmlTextWriter(stringWriter);
IStateFormatter2 formatter = StateFormatter;
RenderTableContents(writer);
writer.Flush();
writer.Close();
string dataKeysString = formatter.Serialize(SaveDataKeysState(), Purpose.WebForms_GridView_DataKeys);
string sortExpressionString = formatter.Serialize(SortExpression, Purpose.WebForms_GridView_SortExpression);
// this should return the html that goes in the panel, plus the new page and sort info.
return Convert.ToString(PageIndex, CultureInfo.InvariantCulture) + "|" + Convert.ToString((int)SortDirection, CultureInfo.InvariantCulture) + "|" + sortExpressionString + "|" + dataKeysString + "|" + stringWriter.ToString();
}
示例12: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
try
{
string ur = DecodeFrom64(DecodeFrom64(TextBox1.Text));
ur = ur.Replace("%3A", ":");
Uri b = new Uri(ur);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(b);
request.Method = "GET";
request.KeepAlive = true;
request.UserAgent = " Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11";
request.CookieContainer = new CookieContainer();
HttpWebResponse HttpWResp = (HttpWebResponse)request.GetResponse();
Stream str = HttpWResp.GetResponseStream();
StreamReader reader;
if(CheckBox1.Checked)
reader = new StreamReader(str, Encoding.UTF8);
else
reader = new StreamReader(str, Encoding.Default);
string d = reader.ReadToEnd();
HttpWResp.Close();
// Response.Write(d);
StringBuilder sb = new StringBuilder(d);
StringWriter writer = new StringWriter(sb);
HtmlTextWriter html = new HtmlTextWriter(writer);
html.Flush();
string htmlString = writer.ToString();
SmtpClient client = new SmtpClient();
client.Port = 587;
client.Host = "smtp.gmail.com";
client.EnableSsl = true;
client.Timeout = 10000;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("[email protected]", "02997105802");
MailMessage mm = new MailMessage("[email protected]", "[email protected]", "test", htmlString);
mm.BodyEncoding = UTF8Encoding.UTF8;
mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
client.Send(mm);
}
catch (Exception ex)
{
if (ex.InnerException != null)
{
Label1.Text = ex.InnerException.ToString();
Label1.BackColor = System.Drawing.Color.Red;
}
else
{
Label1.BackColor = System.Drawing.Color.Red;
Label1.Text = ex.Message;
}
}
}
示例13: Render
//-------------------------------------------------------------------------------------------
protected override void Render(HtmlTextWriter writer)
{
MemoryStream ms = new MemoryStream();
StreamWriter sw = new StreamWriter(ms);
HtmlTextWriter htw = new HtmlTextWriter(sw);
base.Render(htw);
htw.Flush();
ms.Position = 0;
TextReader tr = new StreamReader(ms);
string output = tr.ReadToEnd();
string newOutput = ReplaceWithAppPath(output);
writer.Write(newOutput);
htw.Close();
sw.Close();
ms.Close();
}
示例14: RangerUserControl
/// <summary>
/// 将用户控件转化为HTML代码 并将转化后的HTML代码转换为字符串以供输出
/// </summary>
/// <param name="controlName">用户控件名称</param>
/// <returns>用户控件转换后的HTML代码字符串</returns>
public static string RangerUserControl(string controlName)
{
StringBuilder build = new StringBuilder();
HtmlTextWriter htmlWriter = new HtmlTextWriter(new StringWriter(build));
UserControl uc = new UserControl();
Control ctrl = uc.LoadControl(controlName+".ascx");
htmlWriter.Flush();
string result;
try
{
ctrl.RenderControl(htmlWriter);
}
catch(Exception ex)
{
}
finally
{
htmlWriter.Flush();
result= build.ToString();
}
return result;
}
示例15: Render
protected override void Render(HtmlTextWriter writer)
{
if (IsComponentDesignMode || BXConfigurationUtility.IsDesignMode)
{
HtmlTextWriter writer2 = new HtmlTextWriter(new System.IO.StringWriter(System.Globalization.CultureInfo.CurrentCulture));
base.Render(writer2);
if (BXConfigurationUtility.IsDesignMode)
writer.Write("<pre style='width:500px;overflow:scroll;'>");
else
writer.Write("<pre>");
writer.Write(HttpUtility.HtmlEncode(writer2.InnerWriter.ToString())+"</pre>");
}
else
{
Response.Buffer = true;
writer.Flush();
Response.Clear();
HtmlTextWriter writer2 = new HtmlTextWriter(new System.IO.StringWriter(System.Globalization.CultureInfo.CurrentCulture));
base.Render(writer2);
Response.ContentType = "text/xml";
Response.Write(writer2.InnerWriter.ToString());
Response.End();
}
}