<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
Default.aspx.cs(Code):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Data;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
Button bt;
protected void Page_Load(object sender, EventArgs e)
{
bt = new Button();
bt.ID = "SS";
bt.Text = "Word";
bt.Attributes.Add("style", "font-weight:bold");
bt.Click+=new EventHandler(bt_Click);
form1.Controls.Add(bt);
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("~/App_Data/XMLFile.xml"));
StringBuilder strHtmlContent = new StringBuilder();
strHtmlContent.Append("
Student Information
".ToString());strHtmlContent.Append("
".ToString());
strHtmlContent.Append("
College Name: | A.S COLLEGE,TIRTOL | Date: | 30/12/2011 | |
College Address: | Tirtol,Jagatsinfhpur | Place: | Tirtol | |
Year: | 2011 |
strHtmlContent.Append("
Name | Country | City |
" + ds.Tables[0].Rows[i][0].ToString() + " | " + ds.Tables[0].Rows[i][1].ToString() + " | " + ds.Tables[0].Rows[i][2].ToString() + " |
strHtmlContent.Append("
Signture: | ||
Date: | ||
LblView.Text = strHtmlContent.ToString();
}
protected void btnword_Click(object sender, EventArgs e)
{
Response.Write("Hi.............");
}
protected void bt_Click(object sender, EventArgs e)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentType = "application/msword";
string Filename = "ExportWord" + ".doc";
HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + Filename);
HttpContext.Current.Response.Write(LblView.Text);
HttpContext.Current.Response.End();
HttpContext.Current.Response.Flush();
}
}
No comments:
Post a Comment