本文整理汇总了C#中HtmlTextWriter.Close方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTextWriter.Close方法的具体用法?C# HtmlTextWriter.Close怎么用?C# HtmlTextWriter.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlTextWriter
的用法示例。
在下文中一共展示了HtmlTextWriter.Close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDynamicContent
public static string GetDynamicContent(string contextKey)
{
SqlConnection conn;
SqlCommand cmd;
string cmdString = "Select * from Customers";
switch (contextKey)
{
case ("1"):
cmdString = "Select * from Employees";
break;
case ("2"):
cmdString = "Select * from Products";
break;
}
conn = new
SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\NORTHWND.MDF;Integrated Security=True;User Instance=True");
cmd = new SqlCommand(cmdString, conn);
conn.Open();
SqlDataReader myReader;
myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
DataTable dt = new DataTable();
dt.Load(myReader);
myReader.Close();
GridView myGrid = new GridView();
myGrid.ID = "GridView1";
myGrid.DataSource = dt;
myGrid.DataBind();
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
myGrid.RenderControl(htw);
htw.Close();
return sw.ToString();
}
示例2: 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();
}
示例3: 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();
}
示例4: 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();
}