Skip to main content

Posts

Showing posts from March, 2016

Find First and Last Day of Current Month in SQL Server

In this post I will explain how to get first and last date of month. DECLARE @mydate DATETIME SELECT @mydate = GETDATE() SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)-1),@mydate),103) AS Date_Value, 'First Day OF Current Month' AS Date_Type UNION SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,@mydate))),DATEADD(mm,1,@mydate)),103) , 'Last Day of Current Month' GO

Get Date List From Selected Month in SQL Server

In this post I will explain, How to get Date list of Particular Month. DECLARE @Date DATE='03/15/2016' DECLARE @startDate DATE=CAST(MONTH(@Date) AS VARCHAR) + '/' + '01/' + + CAST(YEAR(@Date) AS VARCHAR) DECLARE @endDate DATE=DATEADD(DAY,-1,DATEADD(MONTH,1,@startDate)) SELECT [Date] = DATEADD(Day,Number,@startDate) FROM master..spt_values WHERE Type='P' AND DATEADD(day,Number,@startDate) <= @endDate

How to Implement Remember Me functionality using CheckBox ASP.Net(C#)

In this post I will explain how to implement Remember me functionality using check box. When the Button btnLogin is clicked the following event handler is executed which first checks whether the chkRememberMe is checked. If it is checked then it save the UserName and Password in the Cookies and sets their expiration date to 30 days in future from the current date. And if it is not checked then it sets the expiration date to 1 day in past so that Cookie is destroyed. Default.aspx <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server">     <title></title> </head> <body>     <form id="form1" runat="server">     UserName:     <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox><br />     Password:     <asp:TextBox ID="txtPassword" TextMode="Password" runat="server"></asp:TextBox>

How to: Save and Retrive Values in Session Asp.net(C#).

What is SessionState? The session state is used to maintain the session of each user throughout the application. Session allows information to be stored in one page and access in another page and support any type of object. In many websites we will see the functionality like once if we login into website they will show username in all the pages for that they will store username in session and they will access that session username in all the pages. Whenever user enters into website new session id will generate for that user. This session Id will delete when he leave from that application. If he enters again he will get new session Id. Default.aspx <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server">     <title>Asp.net Session State Example in C#, VB.NET</title> </head> <body>     <form id="form1" runat="server">     <div>         <table>    

How to: Save and Retrive Values in View State Asp.net(C#).

What is ViewState? ViewState is used to maintain the state of controls during page postback and if we save any control values or anything in viewstate we can access those values throughout the page whenever it required for that check below simple example Default.aspx <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server">     <title>View State in asp.net Example</title> </head> <body>     <form id="form1" runat="server">     <div>         <table>             <tr>                 <td>                     ViewState Data:                 </td>                 <td>                     <b>                         <asp:Label ID="lblString" runat="server" /></b>                 </td>             </tr>             <tr>                 <td>                 </

save data using jQuery Ajax JSON in Asp.net(c#)

Here I will explain simple jQuery ajax json example in asp.net or submit a form without page refresh using jQuery ajax json with example in asp.net using c#  To implement this first design table in your database like below to save values in database. Column Name Data Type Allow Null Name varchar(50) Yes Address varchar(200) Yes Mobileno varchar(50) Yes Default.aspx <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1">     <title>jQuery Submit a form without postback</title>     <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js&q

Select / Deselect all checkboxes using jQuery

first you need to include the jQuery library. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> The “Select all” checkbox have an id #select_all and items checkboxes have a checkbox class. When checkbox with #select_all id is clicked,  If #select_all is checked, loop through each checkbox with class checkbox and check all the checkboxes. Otherwise uncheck all the checkboxes. Once each checkbox is clicked, we will check whether all the checkbox was checked or not. <script type="text/javascript">     $(document).ready(function () {         $('#select_all').on('click', function () {             if (this.checked) {                 $('.checkbox').each(function () {                     this.checked = true;                 });             } else {                 $('.checkbox').each(function () {                     this.checked = false;                 });        

Bind All Countries in Dropdownlist in Asp.net using C#( System.Globalization)

Here I will explain how to bind all countries in dropdownlist in asp.net using c#(System.Globalization) Default.aspx : <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server">     <title>Bind all countries in dropdownlist in asp.net(c#)</title> </head> <body>     <form id="form1" runat="server">     <div>         <b>Country:</b><asp:DropDownList ID="ddlCountry" runat="server" />     </div>     </form> </body> </html> Default.aspx.cs : add following namespaces in code behind using System.Collections.Generic;  protected void Page_Load(object sender, EventArgs e)  {              if (!IsPostBack)             {                 List<string> objcountries = new List<string>();                 CultureInfo[] objCultureInfo = CultureInfo.GetCultures(CultureTypes.SpecificCultures

How to Generate Random OTP(One Time Passsword) in ASP.NET using C#

Here I will explain how to generate random one time password or otp in asp.net using c#. In this we will generate otp using capital and small letters and numbers. Default.aspx : <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server">     <title>Generate Random OTP in Asp.net(C#),Asp.net using C#</title> </head> <body>     <form id="form1" runat="server">     <div>         <asp:Button ID="BtnGenerateOTP" Text="Generate" runat="server"           OnClick="BtnGenerateOTP_Click" /><br />         <asp:Label ID="lblDisplayOTP" runat="server" />     </div>     </form> </body> </html> Default.aspx.cs   protected void BtnGenerateOTP_Click(object sender, EventArgs e)  {             // declare array string to generate random string with combination of small,

How to create and read cookie values in asp.net using c#

Here I will explain how to create and read cookie values in asp.net using c#. By using Response.Cookies and Request.Cookies properties we can create and read cookie values in asp.net using c#. Default.aspx Add this html in your aspx page : <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title>Write and Read Cookies in Asp.net using C#</title> </head> <body>     <form id="form1" runat="server">     <div>         <asp:button id="btnWrite" runat="server" text="Write Cookies" onclick="btnWrite_Click" />         <asp:button id="btnRead" runat="server" text="Read Cookie Values" onclick="btnRead_Click"             />         <br />         <asp:label id="lblResult" runat="server" />     </div>     </form> </body> </htm

Print specific part of web page in ASP.Net(C#).

Here I Will explained how to print particular part of web page in ASP.Net using C# and VB.Net. Using this code you can print content of particular part of web page. <html xmlns="http://www.w3.org/1999/xhtml"> <head>     <title></title>     <script type="text/javascript">         function PrintPanel() {             var panel = document.getElementById("<%=pnlPrint.ClientID %>");             var printWindow = window.open('', '', 'height=600,width=800');             printWindow.document.write('<html><head><title>DIV Text</title>');             printWindow.document.write('</head><body >');             printWindow.document.write(panel.innerHTML);             printWindow.document.write('</body></html>');             printWindow.document.close();             setTimeout(function () {                 printWindow.print(

Post Photo and Status On Facebook using Asp.net(C#).

Here we create one web application for post photo or status on Facebook. First of all we have to download FaceBookAPI.dll from Internet, then after add FaceBookAPI.dll in your project. Then after add name space on code side : using FaceBookAPI Default1.aspx.CS  protected void Page_Load(object sender, EventArgs e) {    FaceBookConnect.Authorize("publish_actions","http://localhost:123/Default2.aspx");   } When we run Default1.aspx then it call Default2.aspx page Default2.aspx <html lang="en">   <head id="Head1" runat="server"> </head>   <body>     <form id="form1" runat="server">         <asp:TextBox ID="txtMessage" runat="server" TextMode="MultiLine"></asp:TextBox>         <asp:FileUpload ID="FileUpload1" runat="server"></asp:FileUpload>         <hr />         <asp:Button ID=&quo