Tuesday, 21 April 2015

Enable Copy Paste On particular control using java script ( when it did on Body)




//HTML

<asp:TextBox runat="server" ID="TextBox1" onmouseover="removeAllAttrs_onmsover();" onmouseout="ADDAllAttrs_onmsout();"></asp:TextBox>


//SCRIPT

                     function removeAllAttrs_ onmsover() {
                        var element = document.body;
                         for (var i = element.attributes.length; i-- > 0; )
                             element.removeAttributeNode(element.attributes[i]);
                     }
                    
                     function ADDAllAttrs_ onmsout(element) {
                         var body = document.getElementsByTagName('body')[0];
                         body.setAttribute("oncopy", "return false;");
                         body.setAttribute("onpaste", "return false;");
                         body.setAttribute("oncut", "return false;");

                       }                  

Generate Random String using Asp.net c#




//Using For loop

public void Generate_Random_String()
    {
        char[] charSet =  "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".ToCharArray();
        string Random_String = "";
        Random RandomNo = new Random();
        byte[] RandomBytes = new byte[32];
        RandomNo.NextBytes(RandomBytes);
       
        for (int i = 0; i < 32; i++)
            Random_String = Random_String + Convert.ToString(charSet[RandomBytes[i] % 62]);
     

    }


//Othere
    public void Generate_RandomString()
    {

        var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        var random = new Random();
        var result = new string(Enumerable.Repeat(chars, 30) .Select(s => s[random.Next(s.Length)]).ToArray())+DateTime.Now.ToString("yyyyMMddhhmmss");

    }


//Result=jdu3tbdi8596mMHFROP20150412042010

Thursday, 16 April 2015

Return array from comma separated string in sql server


declare @outputTable TABLE(
dataTable VARCHAR(256)
)
DECLARE @string VARCHAR(MAX)
DECLARE   @delimiter CHAR(1)
set @string='UK-RUD,UK,RJ-BNS,RJ-J,SWM,JH-DEO,OD-BLR,CG-RJN'
set @delimiter= ','
DECLARE @start INT, @end INT
SELECT @start = 1, @end = CHARINDEX(@delimiter, @string)

WHILE @start < LEN(@string) + 1 BEGIN
IF @end = 0
SET @end = LEN(@string) + 1
INSERT INTO @outputTable (dataTable)
VALUES(SUBSTRING(@string, @start, @end - @start))
SET @start = @end + 1
SET @end = CHARINDEX(@delimiter, @string, @start)
END

select * from @outputTable

//result


Select One by One from comma separated string in sql server query (select multiple table from sql server from comma separated string condition )



DECLARE @string VARCHAR(MAX)
DECLARE   @delimiter CHAR(1)
set @string='RUD,UK-UTT,RJ-BNS,RJ,RJ-SWM,JH-DEO,OD-BLR,RJN,MP-AGR
set @delimiter= ','
DECLARE @start INT, @end INT
SELECT @start = 1, @end = CHARINDEX(@delimiter, @string)

WHILE(@start < LEN(@string) + 1)
BEGIN
IF @end = 0
BEGIN
  
SET @end = LEN(@string) + 1
select * from ‘Table’ where Column=SUBSTRING(@string, @start, @end - @start)
SET @start = @end + 1
SET @end = CHARINDEX(@delimiter, @string, @start)

END

END

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...