本文整理汇总了C#中System.Web.UI.WebControls.WebControl.RenderControl方法的典型用法代码示例。如果您正苦于以下问题:C# WebControl.RenderControl方法的具体用法?C# WebControl.RenderControl怎么用?C# WebControl.RenderControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.WebControl
的用法示例。
在下文中一共展示了WebControl.RenderControl方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderVerbControl
protected virtual void RenderVerbControl(HtmlTextWriter writer, WebControl control)
{
control.ApplyStyle(base.Zone.TitleBarVerbStyle);
control.Page = base.WebPartManager.Page;
control.RenderControl(writer);
}
示例2: RenderButton
void RenderButton(HtmlTextWriter writer)
{
IList<AttributeInfo> attributeInfoByCategoryId = new List<AttributeInfo>();
attributeInfoByCategoryId = ProductBrowser.GetAttributeInfoByCategoryId(this.CategoryId);
if (attributeInfoByCategoryId.Count > 0)
{
for (int i = 0; (i < this.MaxNum) && (i < attributeInfoByCategoryId.Count); i++)
{
WebControl control = new WebControl(HtmlTextWriterTag.Label);
control.Controls.Add(new LiteralControl("<li>"));
control.RenderControl(writer);
WebControl control2 = new WebControl(HtmlTextWriterTag.Label);
control2.Controls.Add(new LiteralControl("<span>" + attributeInfoByCategoryId[i].AttributeName + ":</span>"));
control2.Attributes.Add("class", this.NameCss);
control2.RenderControl(writer);
WebControl control3 = new WebControl(HtmlTextWriterTag.A);
control3.Controls.Add(new LiteralControl("全部"));
if (!this.LinkSelf)
{
control3.Attributes.Add("target", "_blank");
}
string str = "";
if (!string.IsNullOrEmpty(this.ValueStr))
{
string[] strArray = this.ValueStr.Split(new char[] { '-' });
if (strArray.Length >= 1)
{
for (int j = 0; j < strArray.Length; j++)
{
string[] strArray2 = strArray[j].Split(new char[] { '_' });
if ((strArray2.Length > 0) && (strArray2[0].IndexOf(attributeInfoByCategoryId[i].AttributeId.ToString()) != -1))
{
strArray2[1] = "0";
strArray[j] = strArray2[0] + "_" + strArray2[1];
}
if (string.IsNullOrEmpty(str))
{
str = str + strArray[j];
}
else
{
str = str + "-" + strArray[j];
}
}
if (str.IndexOf(attributeInfoByCategoryId[i].AttributeId.ToString()) == -1)
{
object obj2 = str;
str = string.Concat(new object[] { obj2, "-", attributeInfoByCategoryId[i].AttributeId, "_0" });
}
}
}
else
{
str = attributeInfoByCategoryId[i].AttributeId + "_0";
}
if (string.IsNullOrEmpty(this.Page.Request.QueryString["valueStr"]))
{
control3.Attributes.Add("class", this.AllCss);
}
else
{
string str2 = this.Page.Request.QueryString["valueStr"];
if (str2 == str)
{
control3.Attributes.Add("class", this.AllCss);
}
}
control3.Attributes.Add("href", this.CreateUrl(str));
control3.RenderControl(writer);
foreach (AttributeValueInfo info in attributeInfoByCategoryId[i].AttributeValues)
{
WebControl control4 = new WebControl(HtmlTextWriterTag.A);
control4.Controls.Add(new LiteralControl(info.ValueStr));
string str3 = "";
if (!string.IsNullOrEmpty(this.ValueStr))
{
string[] strArray3 = this.ValueStr.Split(new char[] { '-' });
if (strArray3.Length >= 1)
{
for (int k = 0; k < strArray3.Length; k++)
{
string[] strArray4 = strArray3[k].Split(new char[] { '_' });
if ((strArray4.Length > 0) && (strArray4[0].IndexOf(attributeInfoByCategoryId[i].AttributeId.ToString()) != -1))
{
strArray4[1] = info.ValueId.ToString();
strArray3[k] = strArray4[0] + "_" + strArray4[1];
}
if (string.IsNullOrEmpty(str3))
{
str3 = str3 + strArray3[k];
}
else
{
str3 = str3 + "-" + strArray3[k];
}
}
if (str3.IndexOf(attributeInfoByCategoryId[i].AttributeId.ToString()) == -1)
{
object obj3 = str3;
str3 = string.Concat(new object[] { obj3, "-", info.AttributeId, "_", info.ValueId });
//.........这里部分代码省略.........
示例3: RenderButton
void RenderButton(HtmlTextWriter writer)
{
DataTable brandsByCategoryId = ProductBrowser.GetBrandsByCategoryId(this.CategoryId);
if ((brandsByCategoryId != null) && (brandsByCategoryId.Rows.Count > 0))
{
WebControl control = new WebControl(HtmlTextWriterTag.Label);
control.Controls.Add(new LiteralControl("<span>品牌:</span>"));
control.RenderControl(writer);
WebControl control2 = new WebControl(HtmlTextWriterTag.A);
control2.Controls.Add(new LiteralControl("全部"));
control2.Attributes.Add("href", this.urlFormatForALL);
if (this.Context.Request.RawUrl.IndexOf("brand") < 0)
{
control2.Attributes.Add("class", this.AllCss);
}
control2.RenderControl(writer);
foreach (DataRow row in brandsByCategoryId.Rows)
{
WebControl control3 = new WebControl(HtmlTextWriterTag.A);
control3.Controls.Add(new LiteralControl(row["BrandName"].ToString()));
if (this.SelectedBrand == int.Parse(row["BrandId"].ToString()))
{
control3.Attributes.Add("class", this.SelectCss);
}
else
{
control3.Attributes.Add("href", this.urlFormat + row["BrandId"].ToString());
}
control3.RenderControl(writer);
}
}
}
示例4: RenderControl
public static string RenderControl(WebControl control)
{
StringBuilder builder = new StringBuilder();
StringWriter strWriter = new StringWriter(builder);
HtmlTextWriter writer = new HtmlTextWriter(strWriter);
control.RenderControl(writer);
return builder.ToString();
}
示例5: ExportToExcel
///<summary>
///导出到Excel
///</summary>
///<param name="ctrl">包含数据的控件</param>
///<param name="fileName">文件名</param>
public static void ExportToExcel(WebControl ctrl, string fileName)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/ms-excel";
HttpContext.Current.Response.Charset = "UTF-8";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
//HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + "" + fileName + ".xls");
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8) + ".xls");//这样的话,可以设置文件名为中文,且文件名不会乱码。其实就是将汉字转换成UTF8
HttpContext.Current.Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());
StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw);
ctrl.RenderControl(htw);
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();
}
示例6: getHTML
public static String getHTML(WebControl aControl)
{
StringWriter sr = new StringWriter();
HtmlTextWriter writer = new HtmlTextWriter(sr);
aControl.RenderControl(writer);
writer.Dispose();
return sr.ToString();
}
示例7: GetControl
/// <summary>
/// Renders The Given Control Into The String Output
/// </summary>
/// <param name="control">The WebControl To Be Converted</param>
/// <returns>The Rendered Result Of The Given Control</returns>
///
private static string GetControl(WebControl control)
{
StringWriter stringWriter = new StringWriter();
HtmlTextWriter textWriter = new HtmlTextWriter(stringWriter);
control.RenderControl(textWriter);
textWriter.Flush();
return textWriter.ToString();
}