Thursday, 27 July 2017

Sql server paging

// SQL server

Declare @PageNo int=5,@pageSize int=5

select top (@pageSize) * from(select ROW_NUMBER() OVER(ORDER BY hhguid ASC) as line, * from tblhh where createdby=94)mm

where line > (@PageNo - 1) * @pageSize

Monday, 24 July 2017

Check Uncheck all using Jqury with Parent and Child case

// Jquery function

function CheckUncheck_AllCheckBoxes(chk, CheckParentID) {
    $('[id*=' + CheckParentID + ']').find("input:checkbox").each(function () {
        if (this != chk) {
            this.checked = chk.checked;
        }
    });
    return false;

}




// Html or Asp.net

<asp:CheckBox runat="server" ID="Chk_allFrequency"  onclick="CheckUncheck_AllCheckBoxes(this,'Parent ID static');"

 CssClass="pull-left" Text="Frequency" Checked="true" />



                                      

Monday, 17 July 2017

Write exception log in asp.net c#

// Method

private static String ErrorlineNo, Errormsg, extype, exurl, hostIp, ErrorLocation, HostAdd;


public static void Write_Logs(Exception ex)
    {
        var line = Environment.NewLine + Environment.NewLine;

        ErrorlineNo = ex.StackTrace.Substring(ex.StackTrace.Length - 7, 7);
        Errormsg = ex.GetType().Name.ToString();
        extype = ex.GetType().ToString();
        exurl = context.Current.Request.Url.ToString();
        ErrorLocation = ex.Message.ToString();

        try
        {
            string filepath = context.Current.Server.MapPath("~/Ex_Log/");  //Text File Path

            if (!Directory.Exists(filepath))
            {
                Directory.CreateDirectory(filepath);
            }
            filepath = filepath + DateTime.Today.ToString("dd-MM-yy") + ".txt";   //Text File Name
            if (!File.Exists(filepath))
            {
                File.Create(filepath).Dispose();
            }
            using (StreamWriter sw = File.AppendText(filepath))
            {
                sw.WriteLine(line);
                string error = "Date:" + " " + DateTime.Now.ToString() + "," + "LineNo :" + " " + ErrorlineNo + "," + "Message:" + " " + Errormsg + "," + "ExceptionType:" + " " + extype + "," + "Location :" + " " + ErrorLocation + "," + "PageUrl:" + " " + exurl + "," + "HostIP:" + " " + hostIp;
                sw.Flush();
                sw.Close();

            }

        }
        catch (Exception e)
        {
            e.ToString();

        }
    }



//Call


    protected void btn_backCatalogue_Click(object sender, EventArgs e)
    {
        try
        {
        }
        catch (Exception ex)
        {
            Write_Logs(ex);
        }
    }

Saturday, 20 May 2017

Unlock a table using sql server

// Sql Query

select * from  sys.dm_exec_requests

// Result





where status got suspended, get the session_id  of that and execute the query
Query-

kill 57

Related session_id rows status has been changed.

Write excel file and Download file from server using jquery

//

<html>
<head>
    <script>

<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
</head>
<body>
    <a id="lnk" href="data:text/csv;charset=utf-8, asdkjflks" download="FilePath\Exported%20Excel.xls">
        write and download file</a>
    <br>
 
    <script>
        try {
            $('#lnk').on('click', function () {
                window.runnerWindow.proxyConsole.log('The link was clicked')
            });
        }
        catch (error)
        { throw error; }
                //# sourceURL=yereg.js
    </script>
</body>

</html>

Download file from server using jquery

// Using html anchor tag

<html>
<head>
    <script>

<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
</head>
<body>

    <a id="lnk" href="FilePath\Exported%20Excel.xls"
        download="FilePath\Exported%20Excel.xls">download
        file</a>
    <script>
        try {
            $('#lnk').on('click', function () {
                window.runnerWindow.proxyConsole.log('The link was clicked')
            });
        }
        catch (error)
        { throw error; }
                //# sourceURL=yereg.js
    </script>
</body>

</html>

Monday, 15 May 2017

Set Default culture info in asp.net

//  Web.Config file

1.  Set Default cultue info using web.config file

<globalization requestEncoding="utf-8" responseEncoding="utf-8" fileEncoding="utf-8" culture="en-US" uiCulture="en-US" />

2.  Set Default cultue info using Aspx Page

<%@ Page uiCulture="en-US" culture="en-US" %>

3.  Set Default cultue info using web.config using auto select

<globalization requestEncoding="utf-8" responseEncoding="utf-8" fileEncoding="utf-8" culture="auto:en-US" uiCulture="auto:en-US" />

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