Thursday, July 30, 2009

Coding for Checking User Authentication with XML and Create login Details as XML File

XML Files


Create Xml File then use the below code to access.

C# Codings

int i, j;

   
  string users_pass = string.Empty;
  string users_fail = string.Empty;
   
  XmlDocument xml_document = new XmlDocument();
  xml_document.Load(Server.MapPath("Login_Details.xml"));
  XmlNodeList node_list = xml_document.GetElementsByTagName("username");
  for ( i = 0; i < j =" 0;" user_name="node_list[i].ChildNodes[0].InnerText;" pass_word="node_list[i].ChildNodes[1].InnerText;" pass_count =" pass_count" pass_username =" user_name.ToString();" fail_count =" fail_count">= 1)
  {
   string date = System.DateTime.Now.ToShortDateString();
  string date_format = date.Replace('/', '-');
  string path = "Login_info_" + date_format.ToString() + ".XML";
  XmlDocument xml_doc = new XmlDocument();
  xml_doc.Load(Server.MapPath(path));
  XmlNode xml_sel = xml_doc.SelectSingleNode("Login_Details");
  XmlElement xml_ele = xml_doc.CreateElement("Login_Info");
  xml_ele.SetAttribute("user_login", pass_username.ToString());
  xml_sel.AppendChild(xml_ele);
   xml_ele.SetAttribute("login_time", System.DateTime.Now.ToString());
  xml_sel.AppendChild(xml_ele);
  xml_doc.Save(Server.MapPath(path));
  Response.Write("System pass :"+pass_username.ToString());
  pass_count = 0;
  }
  else
  {
  Response.Write("System Fails :"+pass_username.ToString());
  fail_count = 0;
  }

Wednesday, July 22, 2009

Creating Delegates Using C#.net

Creating Of Deletecates Events

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace delegates
{
  ///


  /// Summary description for Delegates
  ///

  public class Delegates : System.Collections.ArrayList
  {
  public event System.EventHandler changed;

  protected virtual void Onchanged(System.EventArgs e)
  {
  if (changed != null)
  {
  changed(this, e);
  }
  }
  public override int Add(object value)
  {
  int i = base.Add(value);
  Onchanged(System.EventArgs.Empty);
  return i;

  }
  public Delegates()
  {

  //
  // TODO: Add constructor logic here
  //
  }
  }

}

Creation Of EventHander and Fucntions

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

///


/// Summary description for delegates_list
///

/// 
using delegates;
namespace delegates_list_pro
{
public class delegates_list
{
  private Delegates list1;
  public delegates_list(Delegates alist)
  {
  list1=alist;
  list1.changed+=new System.EventHandler(listadded);
   
  }
  private void listadded(object sender,EventArgs e)
  {
  System.Windows.Forms.MessageBox.Show("WELCOME");
  }
  public void Detach()
  {
  list1.changed-=new System.EventHandler(listadded);
  list1=null;
  }



 public delegates_list()
 {
  //
  // TODO: Add constructor logic here
  //
 }
}
}

Calling Detlegates and its event handlers from the main program

using delegates;
using delegates_list_pro;

Delegates dele = new Delegates();
delegates_list listener = new delegates_list(dele);
dele.Add("Welcome");
dele.Clear();
listener.Detach();

Thursday, July 2, 2009

Coding for Creating a Window Snap Shot Using C#.net

Add the reference of system.windows.form by address reference option 

using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;

//file name is created based on a time
File_name.Text = System.DateTime.Now.ToShortTimeString();
  string file_name = File_name.Text.Replace(':', '-');
  Bitmap image = new Bitmap(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
  System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(image);  graphics.CopyFromScreen(System.Windows.Forms.Screen.PrimaryScreen.Bounds.X, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Y, 0, 0, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size, System.Drawing.CopyPixelOperation.SourceCopy);
 image.Save("C:/temp/" + file_name.ToString()+".jpg");
Note:
IF You want to take a snap shot for particualr timer interval, just added a meta tag inside head tag
meta http-equiv="refresh" content="60"
60 refers the page refreshing time in a seconds..

Thursday, May 14, 2009

coding for creating video file as ur own using SMIL Concept



use above coding to perform the task.

Before Getting into Coding, try to know abt this smil coding.

This coding run only in Apple's Quicktime player, Windows Media Player, and RealNetworks RealPlayer support SMIL.

Before You run this code, install one of the above software.

Save the file with the extension filename.smil

Run the program thru players mention above

Wednesday, April 22, 2009

Coding for Export Gridview Data into Excel format

Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=C:\\temp\\vijay.xls");//if u want to Export into Document replace vijay.xls with vijay.doc
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vijay.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
GridView1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();

Note:

This method is used to Perform the rendercontrol event.

Add the below function with the coding


public override void VerifyRenderingInServerForm(Control control)
{
}