Monday, March 21, 2011

  if (ds.Tables[0].Rows.Count > 0)
                    {
                        Session["Uid"] = ds.Tables[0].Rows[0]["User_Id"].ToString();
                

Wednesday, March 2, 2011

One click DOWN LOAD DOCUMENT

  string textFile = string.Format("{0}.txt", DateTime.Now.ToString("MM-dd-yyyy_HH-mm-ss"));
 System.IO.StreamWriter streamWriter = File.CreateText(string.Format(@"{0}{1}", "D:\\", textFile));
  streamWriter.WriteLine(Textbox.Text); //( pass the string from which you want get input to write in the doc.)
            streamWriter.Close();
above  works for local


For server :

           textFile = string.Format("{0}.txt", DateTime.Now.ToString("MM-dd-yyyy_HH-mm-ss"));
           // string textFile = string.Format("{0}.txt", DateTime.Now.ToString("MM-dd-yyyy"));
             string kk = string.Format(@"{0}{1}", Server.MapPath("Download/"), textFile).ToString();
            System.IO.StreamWriter streamWriter = File.CreateText(string.Format(@"{0}{1}", Server.MapPath("Download/"), textFile));
            streamWriter.WriteLine(download_htmlcode.ToString());
            streamWriter.Close();

            HttpContext.Current.Response.ContentType = "application/octet-stream";
            //HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName(kk));
            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename="+"Yourdesign");
        
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.WriteFile(kk);
            HttpContext.Current.Response.End();