Click here to Skip to main content
15,897,891 members

Comments by Hari Krishna Prasad Inakoti (Top 134 by date)

Hari Krishna Prasad Inakoti 15-May-14 6:47am View    
public 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();

}
Hari Krishna Prasad Inakoti 11-Mar-14 4:51am View    
Hi Swarup,
I want solution for server side not in client side .

Thanks
Hari Krishna Prasad Inakoti 11-Mar-14 1:26am View    
Hi Arun,
It will accept -(Hypen) and .(dot) also?
Hari Krishna Prasad Inakoti 6-Nov-13 8:34am View    
i did like that only but it was working same.No changes
Hari Krishna Prasad Inakoti 5-Nov-13 8:41am View    
Hi thatraja,
Iam getting same result only. No changes in my report