Sunday, August 18, 2013

Textbox to file and file to textbox conversions in asp.net

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {//code to convert text in a textbox to a file
        TextWriter w = File.CreateText(Server.MapPath("folder/s.xml"));
        w.WriteLine(TextBox1.Text);
        w.Close();

     //code to convert text in a file to textbox
        StreamReader a = File.OpenText(Server.MapPath("folder/ss.txt"));
        String q = a.ReadToEnd();
        TextBox2.Text = q;
        a.Close();


    }
}

No comments:

Post a Comment