Wednesday, 28 November 2018

Redirect web service error to the custom error page in asp.net using Globle.asax and web.config file

////////////////////////   web.config file

  <!--<customErrors mode="On" defaultRedirect="~/Error-page"> </customErrors>-->

--------------------------------------------------
<system.web>
    <webServices>
      <protocols>
        <remove name="Documentation"/>
      </protocols>
    </webServices>
   </system.web>
--------------------------------------------------
  <system.webServer>
<httpErrors errorMode="Custom" defaultResponseMode="Redirect">
      <remove statusCode="404" subStatusCode="-1" />
      <error statusCode="404" prefixLanguageFilePath="" path="~/Path/Error-page"
       responseMode="Redirect" />
      <remove statusCode="403" subStatusCode="-1" />
      <error statusCode="403" prefixLanguageFilePath="" path="~/Path/Error-page"
       responseMode="Redirect" />
      <remove statusCode="405" subStatusCode="-1" />
      <error statusCode="405" prefixLanguageFilePath="" path="~/Path/Error-page"
       responseMode="Redirect" />
    </httpErrors>
</system.webServer>



////////////////////////   web.config file


protected void Application_Error(object sender, EventArgs e)
    {
        Exception exception = Server.GetLastError();
        Response.Clear();

        HttpException httpException = exception as HttpException;

        if (httpException != null)
        {
            string action;

            switch (httpException.GetHttpCode())
            {
                case 404:
                    // page not found
                    action = "~/Error-page";
                    break;
                case 500:
                    // server error
                    action = "~/Error-page";
                    break;
                default:
                    action = "~/Error-page";
                    break;
            }

            // clear error on server
            Server.ClearError();
            Response.Redirect("~/Error-page");
        }
    }

Install windows service using command prompt

//////////////// Steps---------------


Step 1.  C:\Windows\system32>cd /

Step 2. C:\> cd \Windows\Microsoft.NET\Framework>cd v4.0.30319 (press Enter Key)

Step 3. C:\Windows\Microsoft.NET\Framework\v4.0.30319>

for uninstall

Step 4.  C:\Windows\Microsoft.NET\Framework\v4.0.30319>installutil.exe -u D:\FolderPath\WindowsService.exe

for install

Step 5.  C:\Windows\Microsoft.NET\Framework\v4.0.30319>installutil.exe -i D:\FolderPath\WindowsService.exe

                       

Friday, 16 November 2018

Increase font-size click on button using jquery

/////////// HTML

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
    <title>increase or decrease font size of website in asp.net</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            var divtxt = $('#ChDfontdiv');
            // Increase Font Size
            $('#incrsfont').click(function () {
                GetAllSize("p");
            });
            // Decrease Font Size
            $('#decrsfont').click(function () {
                GetAllSize("m");
            })
            function GetAllSize(siz) {
                $('#ChDfontdiv div, #ChDfontdiv span, #ChDfontdiv label, #ChDfontdiv .heading').each(function () {
                    if (siz == "p") {
                        debugger;
                        var curSize = $(this).css('fontSize');
                        var newSize = parseInt(curSize.replace("px", "")) + 1;
                        $(this).css("fontSize", newSize + "px");
                        if (newSize > 12) {
                            $('#decrsfont').removeAttr("disabled");
                        }
                        if (newSize >= 25) {
                            $('#incrsfont').attr("disabled", "disabled");
                        }
                    }
                    else if (siz == "m") {
                        var curSize = $(this).css('fontSize');
                        var newSize = parseInt(curSize.replace("px", "")) - 1;
                        $(this).css("fontSize", newSize + "px");
                        if (newSize <= 12) {
                            $('#decrsfont').attr("disabled", "disabled");
                        }
                        if (newSize < 25) {
                            $('#incrsfont').removeAttr("disabled");
                        }
                    }
                });
            }
        });
    </script>
    <style>
        body{ font-size:12px;}
    .heading{ font-size:18px; font-weight:bold;}
    </style>
</head>
<body>
  
    <div id="ChDfontdiv">
    <div class="heading">
    heading heading heading
    </div>
      <div>div div div div div</div>
        <span>span span span span span</span>
        <label>label label label label label</label>
    </div>
    <br />
    <input type="button" id="incrsfont" value=" + " />
    <input type="button" id="decrsfont" value=" - " />
  
</body>
</html>







Friday, 2 November 2018

Add / Insert Identity column to DataTable in asp.net C#

////////////////////


DataTable dt = new DataTable();

        //Add columns to DataTable.
        dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id"), new DataColumn("Name"), new DataColumn("Country") });

        //Set AutoIncrement True for the First Column.
        dt.Columns["Id"].AutoIncrement = true;

        //Set the Starting or Seed value.
        dt.Columns["Id"].AutoIncrementSeed = 1;

        //Set the Increment value.
        dt.Columns["Id"].AutoIncrementStep = 1;

        //Add rows to DataTable.
        dt.Rows.Add(null, "Raja", "India");
        dt.Rows.Add(null, "Ram", "US");
        dt.Rows.Add(null, "Mohan", "UK");
        dt.Rows.Add(null, "Ray", "Russia");
        dt.Rows.Add(null, "Jai", "China");



Monday, 29 October 2018

Too many fields defined excel import get data

///////////////
Error

too many fields defined


Case-
The internal column count that Microsoft Access uses to track the number of fields in the table has reached 255, even though you may have fewer than 255 fields in the table. This can happen because Access does not change the internal column count when you delete a field. Access also creates a new field (increasing the internal column count by 1) for every field whose properties you modify.

////////////Solution

Where////////////// A1:R51 Sheet range , selected by columns

using (OleDbDataAdapter oda = new OleDbDataAdapter("SELECT * FROM Shee$A1:R51]", excel_con))
{
  oda.Fill(dt);

 }

copy excel sheet name to cell

///////////////////


Select a blank cell, copy and paste the formula =MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)


Tuesday, 23 October 2018

Select Insert into table from another table using sql server

/////////// Sql Query


------------------------- Insert table to table all data
SELECT * INTO newTableName FROM oldTableName WHERE Condition;

------------------------- Insert table to table selected columns
SELECT s.CustomerName, s.OrderID INTO CustomersOrderBackup2017 FROM Customers s LEFT JOIN Orders o ON o.CustomerID = s.CustomerID

------------------------- Insert table to table selected columns with conditions
SELECT s.CustomerName, s.OrderID INTO CustomersOrderBackup2017 FROM Customers s LEFT JOIN Orders o ON o.CustomerID = s.CustomerID WHERE Condition;


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