TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Harsh Jani
NA
34
54k
Export the contents of a Webform to a Text File
Mar 19 2015 3:24 AM
Hi,
I want to export the contents of a Web From to a Text file. I have three text boxes and a Grid View. I want to export these contents to a text file in a proper formatted manner. I have used the following code for the purpose: -
protected void Button1_Click(object sender, EventArgs e)
{
Response.AddHeader("content-disposition", "attachment;filename=Employee.txt");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/text";
StringWriter SW = new StringWriter();
HtmlTextWriter txtWriter = new HtmlTextWriter(SW);
HtmlForm frm = new HtmlForm();
GridView1.Parent.Controls.Add(frm);
frm.Attributes["runat"] = "server";
frm.Controls.Add(txtUName);
frm.Controls.Add(txtEmail);
frm.Controls.Add(txtCity);
frm.Controls.Add(GridView1);
frm.RenderControl(txtWriter);
Response.Write(SW.ToString());
Response.End();
}
This code is working fine but is returning data in HTML format. So, kindly help me out in this regard.
Reply
Answers (
0
)
Auto Complete textbox
when creating report with crystal report with Visual s2012