hello

Thursday, 18 August 2011

how stop cut copy pest

<asp:TextBox ID="TextBox1" runat="server"
oncopy="return false"
onpaste="return false"
oncut="return false">
</asp:TextBox>

Wednesday, 27 July 2011

linq to sql select/insert/update/delete


        DataClassesDataContext db = new DataClassesDataContext();
        var challan = from c in db.viewchallans where c.Brand_Name=="Brand"
                      select c;

        GridView1.DataSource = challan;
        GridView1.DataBind();
        DataClassesDataContext db = new DataClassesDataContext();
        {
            buddget bud = new buddget
            {
                Buddegerbetwwen = "2000000"
            };
            db.buddgets.InsertOnSubmit(bud);
            db.SubmitChanges();
        }
 
        DataClassesDataContext db = new DataClassesDataContext();
        var challan = from c in db.viewchallans where c.Brand_Name.Contains("Brand")
                      select c;
        db.SubmitChanges();





Tuesday, 26 July 2011

search folder from system

using System;
using System.IO;
using System.Collections;

public class RecursiveFileProcessor
{
    public static void Main(string[] args)
    {
        foreach(string path in args)
        {
            if(File.Exists(path))
            {
                // This path is a file
                ProcessFile(path);
            }              
            else if(Directory.Exists(path))
            {
                // This path is a directory
                ProcessDirectory(path);
            }
            else
            {
                Console.WriteLine("{0} is not a valid file or directory.", path);
            }       
        }       
    }





//
  public static void ProcessDirectory(string targetDirectory)
    {
        // Process the list of files found in the directory.
        string [] fileEntries = Directory.GetFiles(targetDirectory);
        foreach(string fileName in fileEntries)
            ProcessFile(fileName);

        // Recurse into subdirectories of this directory.
        string [] subdirectoryEntries = Directory.GetDirectories(targetDirectory);
        foreach(string subdirectory in subdirectoryEntries)
            ProcessDirectory(subdirectory);
    }

    // Insert logic for processing found files here.
    public static void ProcessFile(string path)
    {
        Console.WriteLine("Processed file '{0}'.", path);       
    }
}











Turing in Asp.net

    Bitmap objBMP = new System.Drawing.Bitmap(60, 20);
        Graphics objGraphics = System.Drawing.Graphics.FromImage(objBMP);
        objGraphics.Clear(Color.Chocolate);
        objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
        //' Configure font to use for text
        Font objFont = new Font("Arial", 8, FontStyle.Bold);
        string randomStr = "";
        int[] myIntArray = new int[5];
        int x;
        //That is to create the random # and add it to our string
        Random autoRand = new Random();
        for (x = 0; x < 5; x++)
        {
            myIntArray[x] = System.Convert.ToInt32(autoRand.Next(0, 9));
            randomStr += (myIntArray[x].ToString());
        }
        //This is to add the string to session cookie, to be compared later
        Session.Add("randomStr", randomStr);
        //' Write out the text
        objGraphics.DrawString(randomStr, objFont, Brushes.White, 3, 3);
        //' Set the content type and return the image
        Response.ContentType = "image/GIF";
        objBMP.Save(Response.OutputStream, ImageFormat.Gif);
        objFont.Dispose();
        objGraphics.Dispose();
        objBMP.Dispose();

 if (Page.IsValid && (txtTuring.Text == Session["randomStr"].ToString()))
                {
}

convert date dd/mm/yyyy to mm/dd/yyyy in asp.net

   DateTime dtt1;
                dtt1 = Convert.ToDateTime(txtDD.Text, System.Globalization.CultureInfo.CreateSpecificCulture("en-CA"));

globla .asax file in asp.net

 void Session_Start(object sender, EventArgs e)
    {
        // Code that runs when a new session is started
        Session.Timeout = 1440;       
       
        Session["user"] = "";
        Session["LoginBy"] = "";



    }

array in data set

 for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
        {

            String m = ds.Tables[0].Rows[i].ItemArray[0].ToString();
            String m1 = ds.Tables[0].Rows[i].ItemArray[6].ToString();
            String m2 = ds.Tables[0].Rows[i].ItemArray[12].ToString();
            string m3 = ds.Tables[0].Rows[i].ItemArray[13].ToString();
            string insert = "insert into table(aaa,aa,aa,aa) values('" + Gpcode + "','" + m + "','" + m1 + "','" + m2 + "')";
            SqlHelper.ExecuteNonQuery(con, CommandType.Text, insert);

        }