本文整理汇总了C#中System.Web.UI.HtmlControls.HtmlForm类的典型用法代码示例。如果您正苦于以下问题:C# HtmlForm类的具体用法?C# HtmlForm怎么用?C# HtmlForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HtmlForm类属于System.Web.UI.HtmlControls命名空间,在下文中一共展示了HtmlForm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Boton_Excel_Dios_Click
protected void Boton_Excel_Dios_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter htw = new HtmlTextWriter(sw);
Page page = new Page();
HtmlForm form = new HtmlForm();
GridView_Dios.DataSourceID = string.Empty;
GridView_Dios.EnableViewState = false;
GridView_Dios.AllowPaging = false;
GridView_Dios.DataSource = LBPD.Logica_Mostrar_Precios();
GridView_Dios.DataBind();
page.EnableEventValidation = false;
page.DesignerInitialize();
page.Controls.Add(form);
form.Controls.Add(GridView_Dios);
page.RenderControl(htw);
Response.Clear();
Response.Buffer = true;
Response.ContentType = "applicattion/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename=data.xls");
Response.Charset = "UTF-8";
Response.ContentEncoding = Encoding.Default;
Response.Write(sb.ToString());
Response.End();
}
示例2: PrintWebControl
public void PrintWebControl(Control ControlToPrint)
{
StringWriter stringWrite = new StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
if (ControlToPrint is WebControl)
{
Unit w = new Unit(100, UnitType.Percentage);
((WebControl)ControlToPrint).Width = w;
}
Page pg = new Page();
pg.EnableEventValidation = false;
HtmlForm frm = new HtmlForm();
pg.Controls.Add(frm);
frm.Attributes.Add("runat", "server");
frm.Controls.Add(ControlToPrint);
pg.DesignerInitialize();
pg.RenderControl(htmlWrite);
string strHTML = stringWrite.ToString();
string wstawka = Server.MapPath("~").ToString();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Write(htmlToImage(strHTML, zmianaAdresu(wstawka)));
HttpContext.Current.Response.Write("<script>window.print();</script>");
HttpContext.Current.Response.End();
Response.Redirect("~/ListaImprez.aspx");
}
示例3: PrintWebControl
public static void PrintWebControl(Control ControlToPrint, Control MyStyle)
{
StringWriter stringWrite = new StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
if (ControlToPrint is WebControl)
{
Unit w = new Unit(100, UnitType.Percentage);
((WebControl)ControlToPrint).Width = w;
}
System.Web.UI.Page pg = new System.Web.UI.Page();
pg.EnableEventValidation = false;
HtmlForm frm = new HtmlForm();
frm.Controls.Add(MyStyle);
pg.Controls.Add(frm);
frm.Attributes.Add("runat", "server");
frm.Controls.Add(ControlToPrint);
pg.DesignerInitialize();
pg.RenderControl(htmlWrite);
string strHTML = stringWrite.ToString();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Write(strHTML);
HttpContext.Current.Response.Write("<script>window.print();</script>");
HttpContext.Current.Response.End();
}
示例4: RenderControl
public static string RenderControl(string path, object data)
{
Page pageHolder = new Page();
pageHolder.EnableEventValidation = false;
UserControl viewControl = (UserControl)pageHolder.LoadControl(path);
if (data != null)
{
Type viewControlType = viewControl.GetType();
FieldInfo field = viewControlType.GetField("Data");
if (field != null)
{
field.SetValue(viewControl, data);
}
else
{
throw new Exception("View file: " + path + " does not have a public Data property");
}
}
HtmlForm _form = new HtmlForm();
pageHolder.Controls.Add(_form);
_form.Controls.Add(viewControl);
StringWriter output = new StringWriter();
HttpContext.Current.Server.Execute(pageHolder, output, false);
return output.ToString();
}
示例5: PrintWebControl
public static void PrintWebControl(Control ctrl, string Script)
{
StringWriter stringWrite = new StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
if (ctrl is WebControl)
{
Unit w = new Unit(100, UnitType.Percentage); ((WebControl)ctrl).Width = w;
}
Page pg = new Page();
pg.EnableEventValidation = false;
if (Script != string.Empty)
{
pg.ClientScript.RegisterStartupScript(pg.GetType(), "PrintJavaScript", Script);
}
HtmlForm frm = new HtmlForm();
pg.Controls.Add(frm);
frm.Attributes.Add("runat", "server");
frm.Controls.Add(ctrl);
pg.DesignerInitialize();
pg.RenderControl(htmlWrite);
string strHTML = stringWrite.ToString();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Write(strHTML);
HttpContext.Current.Response.Write("<script>window.print();</script>");
HttpContext.Current.Response.End();
}
示例6: imgBtnExportarExcelArchivos_Click
protected void imgBtnExportarExcelArchivos_Click(object sender, ImageClickEventArgs e)
{
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter htw = new HtmlTextWriter(sw);
Page page = new Page();
HtmlForm form = new HtmlForm();
gvJobCancelacioneXTicket.AllowPaging = false;
gvJobCancelacioneXTicket.DataBind();
gvJobCancelacioneXTicket.EnableViewState = false;
page.EnableEventValidation = false;
page.DesignerInitialize();
page.Controls.Add(form);
form.Controls.Add(gvJobCancelacioneXTicket);
page.RenderControl(htw);
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename=ArchivosDeProcedimiento.xls");
Response.Charset = "UTF-8";
//Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentEncoding = System.Text.Encoding.Default;
Response.Write(sb.ToString());
Response.End();
}
示例7: imgBtnExportarExcelEjecucion_Click
protected void imgBtnExportarExcelEjecucion_Click(object sender, ImageClickEventArgs e)
{
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter htw = new HtmlTextWriter(sw);
Page page = new Page();
HtmlForm form = new HtmlForm();
gvIncidenciasBatch.AllowPaging = false;
gvIncidenciasBatch.DataBind();
gvIncidenciasBatch.EnableViewState = false;
page.EnableEventValidation = false;
page.DesignerInitialize();
page.Controls.Add(form);
form.Controls.Add(gvIncidenciasBatch);
page.RenderControl(htw);
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename=ReporteIncidenciasBatch" + DateTime.Now.ToShortDateString() + ".xls");
Response.Charset = "UTF-8";
Response.ContentEncoding = System.Text.Encoding.Default;
Response.Write(sb.ToString());
Response.End();
}
示例8: PrintWebControl
public static void PrintWebControl(Control ctrl, string Script)
{
StringWriter stringWrite = new StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
if (ctrl is WebControl)
{
Unit w = new Unit(100, UnitType.Percentage); ((WebControl)ctrl).Width = w;
}
Page pg = new Page();
pg.EnableEventValidation = false;
pg.StyleSheetTheme = "../CSS/order.css";
if (Script != string.Empty)
{
pg.ClientScript.RegisterStartupScript(pg.GetType(), "PrintJavaScript", Script);
}
HtmlLink link = new HtmlLink();
link.Href = "../CSS/order.css";
HtmlForm frm = new HtmlForm();
pg.Controls.Add(frm);
frm.Attributes.Add("runat", "server");
frm.Controls.Add(ctrl);
pg.DesignerInitialize();
pg.RenderControl(htmlWrite);
string strHTML = stringWrite.ToString();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Write("<head runat='server'> <title>Printer - Bản in tại Support.evnit.evn.com.vn</title> <link type='text/css' rel='stylesheet' href='../CSS/order.css'><link type='text/css' rel='stylesheet' href='../CSS/style.css'></head>");
HttpContext.Current.Response.Write(strHTML);
HttpContext.Current.Response.Write("<script>window.print();</script>");
HttpContext.Current.Response.End();
}
示例9: btnexporttoexc_Click
protected void btnexporttoexc_Click(object sender, EventArgs e)
{
try
{
string sysDates = DateTime.Now.ToString("dd/MM/yyyy");
string FileName = sysDates;
string strFileName = FileName + ".xls";
btnSearch_Click(sender, e);
//GridViewExportUtil.ExportExcell(strFileName, Grdiworkreg);
string attachment = "attachment; filename=" + strFileName + " ";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
HtmlForm frm = new HtmlForm();
GridView2.AllowPaging = false;
GridView2.Parent.Controls.Add(frm);
frm.Attributes["runat"] = "server";
frm.Controls.Add(GridView2);
frm.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
catch (Exception ex)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('" + ex.Message + "');", true);
}
}
示例10: xlsport
public static void xlsport(GridView grd, string _fnm, Page p)
{
grd.Visible = true;
gridstrip(grd);
grd.DataBind();
HtmlForm form = new HtmlForm();
string attachment = "attachment; filename=" + _fnm + csclass.ranfn() + ".xls";
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.AddHeader("content-disposition", attachment);
HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
p.EnableViewState = false;
HttpContext.Current.Response.Charset = string.Empty;
System.IO.StringWriter stw = new System.IO.StringWriter();
HtmlTextWriter htextw = new HtmlTextWriter(stw);
form.Controls.Add(grd);
p.Controls.Add(form);
form.RenderControl(htextw);
HttpContext.Current.Response.Write(stw.ToString());
HttpContext.Current.Response.End();
}
示例11: OnPreInit
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
foreach (Control control in Controls)
{
if (regForm == null)
{
regForm = control as HtmlForm;
if (regForm != null) break;
}
}
if (regForm == null)
{
throw new ArgumentException("登录页面中至少添加一个服务器端表单");
}
window = new Window();
window.Title = "管理员注册";
window.Closable = false;
window.Icon = Icon.Key;
window.Width = 320;
window.Height = 185;
formPanel = new FormPanel();
formPanel.BodyStyle = "padding:20px;";
formPanel.Layout = "table";
formPanel.LayoutConfig.Add(new TableLayoutConfig()
{
Columns = 2
});
formPanel.Items.Add(new TextField()
{
FieldLabel = "用户名",
AllowBlank = false,
ColSpan = 2,
Name = "Username"
});
formPanel.Items.Add(new TextField()
{
FieldLabel = "密码",
AllowBlank = false,
ColSpan = 2,
InputType = Ext.Net.InputType.Password,
Name = "Password"
});
formPanel.Items.Add(new TextField()
{
FieldLabel = "确认密码",
AllowBlank = false,
ColSpan = 1,
InputType = Ext.Net.InputType.Password,
Name = "Password2"
});
window.Items.Add(formPanel);
regForm.Controls.Add(window);
btnReg = new KeyAddButton();
btnReg.Text = "注册";
btnReg.ID = "btnReg";
btnReg.OnClientClick = "App.direct.Reg({eventMask:{showMask:true,msg:'正在注册'}});";
window.Buttons.Add(btnReg);
}
示例12: Export
protected bool Export()
{
try
{
//Descargo el objeto tabla de la sesion con nombre "p_c" ó (Plan Operativo)
HtmlTable objTable = (HtmlTable)Session["p_c"];
//Instancio un objeto del tipo StringBuilder objsb
StringBuilder objsb = new StringBuilder();
//Instancio un objeto del tipo System.IO.StringWriter sw
System.IO.StringWriter sw = new System.IO.StringWriter(objsb);
//Instancio un objeto del tipo HtmlTextWriter htw
HtmlTextWriter htw = new HtmlTextWriter(sw);
//Instancio un objeto del tipo System.Web.UI.Page
System.Web.UI.Page pagina = new System.Web.UI.Page();
//Instancio un objeto del tipo HtmlForm
var form = new HtmlForm();
//Asigno valores a propiedades del objeto page instanciado
pagina.EnableEventValidation = false;
pagina.DesignerInitialize();
//Agrego el formulario instaciado a la coleccionde paginas
pagina.Controls.Add(form);
//Agrego el objeto tabla a la coleccion de controles del formulario instanciado anteriormente
form.Controls.Add(objTable);
//Realizo el proceso de renderizacion para los elementos agregados a la pagina instanciada
pagina.RenderControl(htw);
//Limpio el canal de respuesta para esta peticion
Response.Clear();
//Habilito el buffer
Response.Buffer = true;
//Asigno el tipo de contenido
Response.ContentType = "application/vnd.ms-excel";
//Asigno el nombre del documento a exportar en el header del response
Response.AddHeader("Content-Disposition", "attachment;filename=Plan_Operativo.xls");
//Asigno el tipo de charset "UTF-8"
Response.Charset = "UTF-8";
//Establesco la configuracion por defecto para la codificacion
Response.ContentEncoding = Encoding.Default;
//Realizo el proceso de escritura para el objeto objsb
Response.Write(objsb.ToString());
//Finalizo la respuesta
Response.End();
return true;
}
catch (Exception) { return false; }
}
示例13: GetControlHtml
public string GetControlHtml(string controlLocation)
{
Page page = new Page();
UserControl userControl = (UserControl)page.LoadControl(controlLocation);
userControl.EnableViewState = false;
HtmlForm form = new HtmlForm();
form.Controls.Add(userControl);
page.Controls.Add(form);
StringWriter textWriter = new StringWriter();
HttpContext.Current.Server.Execute(page, textWriter, false);
return CleanHtml(textWriter.ToString());
}
示例14: imgBtnExcel_Click
protected void imgBtnExcel_Click(object sender, ImageClickEventArgs e)
{
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter htw = new HtmlTextWriter(sw);
Page page = new Page();
HtmlForm form = new HtmlForm();
gdUsuario.EnableViewState = false;
// Deshabilitar la validación de eventos, sólo asp.net 2
page.EnableEventValidation = false;
// Realiza las inicializaciones de la instancia de la clase Page que requieran los diseñadores RAD.
page.DesignerInitialize();
page.Controls.Add(form);
form.Controls.Add(gdUsuario);
page.RenderControl(htw);
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename=datosHotel.xls");
Response.Charset = "UTF-8";
Response.ContentEncoding = Encoding.Default;
Response.Write(sb.ToString());
Response.End();
//Response.Clear();
//Response.AddHeader("content-disposition", "attachment;filename=Catalogo_Productos.xls");
//Response.Charset = "";
//Response.ContentType = "application/vnd.xls";
//StringWriter StringWriter = new System.IO.StringWriter();
//HtmlTextWriter HtmlTextWriter = new HtmlTextWriter(StringWriter);
//gvDatosAdmin.AllowPaging = false;
//Response.Write(StringWriter.ToString());
//Response.End();
}
示例15: TryGetControlFromXElement
// IXElementToControlMapper
public bool TryGetControlFromXElement(XElement element, out Control control)
{
if (element.Name.Namespace != Namespaces.AspNetControls)
{
control = null;
return false;
}
if (element.Name == _markerElementName)
{
control = _controls[element.Attribute("key").Value];
return true;
}
if (element.Name == _formElementName)
{
control = new HtmlForm();
element.CopyAttributes(control as HtmlForm, false);
foreach (var child in element.Nodes())
{
control.Controls.Add(child.AsAspNetControl(this));
}
return true;
}
if (element.Name == _placeholderElementName)
{
control = new PlaceHolder();
XAttribute idAttribute = element.Attribute("id");
if (idAttribute != null)
{
control.ID = idAttribute.Value;
}
foreach (var child in element.Nodes())
{
control.Controls.Add(child.AsAspNetControl(this));
}
return true;
}
throw new InvalidOperationException(string.Format("Unhandled ASP.NET tag '{0}'.", element.Name));
}