Friday, May 1, 2015

asp.net convert to string

  public static string ToString(object value)
        {
            if (IsDBNull(value))
                return "";
            else if (value == "")
                return "";
            else
                return (Convert.ToString(value));
        }

asp.net check is DBNull

    public static bool IsDBNull(object value)
        {
            if (value is DBNull)
                return true;
            else
                return false;
        }

asp.net convert string to byte

 public static byte[] StringToByte(string str)
        {
            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
            return encoding.GetBytes(str);
        }

asp.net convert byte to string

 public static string ByteToString(Object byteObject)
        {
            string returnString;
            byte[] byteValue;
            try
            {
                if (byteObject.GetType().ToString() == "System.Byte[]")
                {
                    byteValue = (byte[])byteObject;
                    System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
                    returnString = asciiEncoding.GetString(byteValue);
                }
                else
                    returnString = byteObject.ToString();
            }
            catch (BaseException ex)
            {
                throw ex;
            }
            return returnString;
        }

sql change table column data type

alter table mst_school_details
alter column sport_equipment varchar(50)

Thursday, April 30, 2015

jQuery and JavaScript Coding: Examples and Best Practices - RULE #1: SEPARATE JAVASCRIPT FUNCTIONALITY

CrossBad markup:
Never include Javascript events as inline attributes. This practice should be completely wiped from your mind.
<a onclick="doSomething()" href="#">Click!</a>
TickGood markup:
All Javascript behaviours should be included in external script files and linked to the document with a <script> tag in the head of the page. So, the anchor tag would appear like this:
<a href="backuplink.html" class="doSomething">Click!</a>
And the Javascript inside the myscript.js file would contain something like this:
...

$('a.doSomething').click(function(){
 // Do something here!
 alert('You did something, woo hoo!');
});
...

Wednesday, April 29, 2015

SQL Insert mutiple values to table

Database - Insert into mst_type(work_type_id,sub_work_type,record_status,create_user,create_stamp,update_user,update_stamp)
values (9,'Primary','A','system',GETDATE(),'system',GETDATE()),
(9,'Center','A','system',GETDATE(),'system',GETDATE()),
(9,'Medical','A','system',GETDATE(),'system',GETDATE()),
(9,'Staff','A','system',GETDATE(),'system',GETDATE()),
(9,'Aanganwadi','A','system',GETDATE(),'system',GETDATE()),
(9,'School','A','system',GETDATE(),'system',GETDATE()),
(9,'Village','A','system',GETDATE(),'system',GETDATE()),
(9,'Samajik Sabhagruha','A','system',GETDATE(),'system',GETDATE()),
(9,'Shopping Center Building','A','system',GETDATE(),'system',GETDATE()),
(9,'Veternary Hospital','A','system',GETDATE(),'system',GETDATE()),
(9,'Mahila Work Shed Building','A','system',GETDATE(),'system',GETDATE()),
(9,'Product Selling Stall','A','system',GETDATE(),'system',GETDATE()),
(9,'Office Building','A','system',GETDATE(),'system',GETDATE()),
(9,'Staff Quarter Building','A','system',GETDATE(),'system',GETDATE()),
(9,'Smashan Bhumi','A','system',GETDATE(),'system',GETDATE()),
(9,'Toilet Blocks','A','system',GETDATE(),'system',GETDATE()),
(10,'Major Bridge','A','system',GETDATE(),'system',GETDATE()),
(10,'Minor Bridge','A','system',GETDATE(),'system',GETDATE()),
(10,'Culverts','A','system',GETDATE(),'system',GETDATE())