Posts

Get The Details Of Identity Columns in a Table in sql server

To get the current value: SELECT IDENT_CURRENT('Table Name') As currentValue To get the Identitity seed: SELECT IDENT_SEED('Table Name')As identitySeed To get the Identity Increement SELECT IDENT_INCR('Table Name') As IdendityIncreement

Calling server side functions using ajax in javascript

In the javascript side <script> function insertValue(){  $.ajax({                             type: "POST",                             url: "Default.aspx/serverFunction",                             data: '{path: "' + path + '"}',                             contentType: "application/json; charset=utf-8",                       ...

open a new window with button inside an ajax update panel

 ScriptManager.RegisterClientScriptBlock(UpdatePanel1, UpdatePanel1.GetType(), "Any Name you Like", "Window.open('default.aspx','','height=100,width=100');", true);

Simple string encoding and decoding in c#

public string Decode(string sData)         {             System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();             System.Text.Decoder utf8Decode = encoder.GetDecoder();             byte[] todecode_byte = Convert.FromBase64String(sData);             int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);             char[] decoded_char = new char[charCount];             utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);             string result = new String(decoded_char);     ...

Sending mail in asp.net using gmail gateway

using System.Net.Mail; ......... ......... public string SendMail(string uname,string password, string To, string Subject, string Body)     {         string fromid = uname;         string mypass = password;         try         {             //Create Mail Message Object with content that you want to send with mail.             MailMessage MyMailMessage = new MailMessage(fromid, To, Subject, Body);             MyMailMessage.IsBodyHtml = true;             //Proper Authentication Details need to be passed when sending email from gmail             Syst...

Shuffling a sequence of numbers in an array.

here this code will randomly shuffle consecutive series of numbers, from 1 up to 1000. int[] theArray = new int[1000];             int i = 0;             while (i < theArray.Length)             {                 theArray[i] = ++i;             }             // Work backward, swapping the last unswapped entry with any of the             // remaining unswapped entries - including possibly itself.             // This is really just slightly complicated way of doing a random 'draw',         ...

Auto Complete Ajax Control

Ever wonder how to auto complete your textbox with the data in your database....? Well you can use the cumbersome ajax code or simply use the .net ajax toolkit controll. Here is how you can use it.... (Before starting make sure you installed the ajax tool kit package in your visual studio) 1. Add a textbox on your page 2. Add the 'AutoComplete' Extender from the smart tag. 3. Add a script manager any where above it. 4.Again in the smart tag click the 'Add autocomplete page method' a new web method in the .cs(code source page) page will appear. we can use that method as given in the below example. eg:  [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]     public static string[] GetCompletionList(string prefixText, int count, string contextKey)     {         List<string> name = new List<string>();         Strin...