Asp.Net

Tuesday 29 October 2013

Difference between two dates in C#!!

Console Applications:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {

            DateTime d1 = DateTime.Now;
            DateTime d2 = DateTime.Now.AddDays(2);
            TimeSpan span = d2 - d1;
            Console.WriteLine("There're {0} days between {1} and {2}", span.TotalDays, d1.ToString(), d2.ToString());
            Console.ReadLine();
          
        }
    }
}

Thursday 24 October 2013

Ajax simple Example

ASPX page

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>


<asp:ToolkitScriptManager ID="kbk" runat="server"></asp:ToolkitScriptManager>
    <asp:TextBox ID="txt" runat="server"></asp:TextBox>
    <asp:CalendarExtender ID="CalendarExtender1" runat="server" PopupButtonID="txt" TargetControlID="txt">
</asp:CalendarExtender>


Thursday 3 October 2013

JQuery example

1st download jQuery from google i e : jquery-1.10.2.min.js

aspx.aspx:

<body>
    <form id="form1" runat="server">
    <div>
    <script src="jquery-1.10.2.min.js" type="text/javascript"></script>
    <script src="Validation.js" type="text/javascript"></script>
   
<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
<asp:Button ID="btnsubmit" runat="server" />
   
    </div>
    </form>
</body>
Validation.js:

$(document).ready(function () {
    $('#btnsubmit').click(function () {
        if ($('#txtname').val() == '') {
            alert("please enter the name");
            return false;
        }
    });
});

Tuesday 1 October 2013

Navigation to the different files

1st add a file to the project, then in asp.aspx put in hyperlink button and in design part set that navigate url to the specified as below

<asp:HyperLink ID="hyp" runat="server"
            NavigateUrl="~/pdf/ASP.NET Interview Questions.doc">registration</asp:HyperLink>