Friday, 23 October 2015

Split first-name middle-name and last-name from full name using sql query


// using SUBSTRING

declare @name varchar(50)='krishna-chaturvedi'
SELECT top 2 SUBSTRING(@name, CHARINDEX('-', @name)+1, 8000)+'/' +SUBSTRING(@name, CHARINDEX('-', @name) + 1, 8000)

FROM mstuser


// using PARSENAME


declare @name varchar(100)= 'krishna-kumar-chaturvedi'
Select PARSENAME (Replace(@name,'-','.'),1)[LastName],
            PARSENAME (Replace(@name,'-','.'),2) [MiddleName],

            PARSENAME (Replace(@name,'-','.'),3)[FristName]

Tuesday, 20 October 2015

Encrypt password using sql server query with SHA and HASHBYTES



DECLARE @HashThis nvarchar(4000);
SELECT @HashThis = CONVERT(nvarchar(4000),'abc');

SELECT HASHBYTES('SHA1', @HashThis);

Encrypt and Decrypt password using sql server query



//1.   with query and parameter

declare @encrypt varbinary(200)
select @encrypt = EncryptByPassPhrase('key', 'abc' )
select @encrypt

select convert(varchar(100),DecryptByPassPhrase('key',@encrypt))


//2.   with query and direct value

declare @encrypt varbinary(200)
select @encrypt = EncryptByPassPhrase('key', 'abc' )
select @encrypt

select convert(varchar(100),DecryptByPassPhrase('key',0x01000000B97F1BA787918D419080AA009A4AC2B04628AFEAC1C1FBFD))

Tuesday, 6 October 2015

Rotate text inside gridview in asp.net using css for (IE,Mozial,Chrome etc.)

.verticaltext
{
/*I method
filter: flipH() flipV();
writing-mode: tb-rl;
height:128px;
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
width:50px;
*/
/*II method*/
position: relative;
 -moz-transform: rotate(270deg);  /* FF3.5+ */      
 -o-transform: rotate(270deg);  /* Opera 10.5 */  
 -webkit-transform: rotate(270deg);  /* Saf3.1+, Chrome */            
  filter:  progid:DXImageTransform.Microsoft.BasicImage(rotation=3);  /* IE6,IE7 */        
  -ms-filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); /* IE8 */
  height:150px;

}

Friday, 25 September 2015

Show browser file or input type=file show only button in asp.net or HTML


//CSS

input[type=file] {
position: absolute;
border: solid transparent;
border-width: 0 0 0px 0px;
opacity: 0.0;
filter: alpha(opacity = 0);
}
.filebutton {
position: relative;
cursor: pointer;
text-align: center;
}
.filebutton span {
text-align: center;
padding: 2px 6px 3px;
background: #eac380 -moz-linear-gradient(center top , #eac380 5%, #fae4bd 100%) repeat scroll 0 0;
display: inline-block;

}

// HTML Controls

<label class=" filebutton">
   <span>Add Files</span>
   <input type="file" id="files" name="file"></input>
</label>

// Asp.net Controls

                               <label class="filebutton">
                                  <span>Browse...</span>
                                  <asp:FileUpload ID="FileUpload1" runat="server"/>
                              </label>

Thursday, 24 September 2015

How can I format currency by simple using JQuery in all format

// HTML

<input type='text' id='currency'/>


//JS

$('#currency').keyup(function (e) {
            $(this).val(formatCurrency(this.value.replace(/[,$]/g, '')));
        }).on('keypress', function (e) {
            if (!$.isNumeric(String.fromCharCode(e.which))) e.preventDefault();
        }).on('paste', function (e) {
            var cb = e.originalEvent.clipboardData || window.clipboardData;
            if (!$.isNumeric(cb.getData('text'))) e.preventDefault();
        });
        function formatCurrency(number) {
            var x = number.toString();
            var lastThree = x.substring(x.length - 3);
            var otherNumbers = x.substring(0, x.length - 3);
            if (otherNumbers != '')
                lastThree = ',' + lastThree;
            return otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + lastThree;
        }


// Result 



1,11,11,111

Saturday, 5 September 2015

jQuery Show upload button instead of file upload



<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Show upload button instead of file upload</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
    $(function () {
        $("#fileupload1").change(function () {
            $("#FileName").html($("#fileupload_Dilog").val().substring($("#fileupload_Dilog").val().lastIndexOf('\\') + 1));
        });
    });
</script>
<style type="text/css">
.button {
background: #333;
color: #fff;
padding: 10px 15px;
border-radius: 5px;
}
.button:hover {
background: #51A8CA;
}
</style>
</head>
<body>
<form id="form1>
<div><br />
<input style="display:none" type="file" id="fileupload_Dilog" />
<input type="button" class="button" id="btnUpload" onclick='$("#fileupload_Dilog").click()' value="Upload"/>
<span id="FileName"></span>
</div>
</form>
</body>
</html>



How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...