top of page

A Basic .Net Program

(https://www.guru99.com/insert-update-delete-asp-net.html)

 

<html xmlns="www.w3.org/1999/xhtml">

<head runat="server">

        <title></title>

</head>

<body>

        <form id="form1" runat="server">

        <div>

 

        <%Response. Write( "HeIIo World"); %>

 

        </div>

        </form>

</body>

</html>

Convert String into a DateTime

string dateInput = "Jan 1, 2009";

var parsedDate = DateTime.Parse(dateInput);

Console.WriteLine(parsedDate);

// Displays the following output on a system whose culture is en-US:

//      

           1/1/2009 00:00:00

Example of using the DayOfWeek property

https://docs.microsoft.com/en-us/dotnet/api/system.datetime.hour?view=net-6.0

// This example demonstrates the DateTime.DayOfWeek property

 

using System;

class Sample

{

    public static void Main()

    {

// Assume the current culture is en-US.

// Create a DateTime for the first of May, 2003.

    DateTime dt = new DateTime(2003, 5, 1);

    Console.WriteLine("Is Thursday the day of the week for {0:d}?: {1}",

                       dt, dt.DayOfWeek == DayOfWeek.Thursday);

    Console.WriteLine("The day of the week for {0:d} is {1}.", dt, dt.DayOfWeek);

    }

}

/*

This example produces the following results:

 

Is Thursday the day of the week for 5/1/2003?: True

The day of the week for 5/1/2003 is Thursday.

*/

Example of using the Hour property

 https://docs.microsoft.com/en-us/dotnet/api/system.eventhandler?view=net-6.0

 

System.DateTime moment = new System.DateTime(

                                1999, 1, 13, 3, 57, 32, 11);

// Year gets 1999.

int year = moment.Year;

 

// Month gets 1 (January).

int month = moment.Month;

 

// Day gets 13.

int day = moment.Day;

 

// Hour gets 3.

int hour = moment.Hour;

 

// Minute gets 57.

int minute = moment.Minute;

 

// Second gets 32.

int second = moment.Second;

 

// Millisecond gets 11.

int millisecond = moment.Millisecond;

Example of Using the Minute property

https://docs.microsoft.com/en-us/dotnet/api/system.datetime.minute?view=net-6.0

 

 

System.DateTime moment = new System.DateTime(

                                1999, 1, 13, 3, 57, 32, 11);

// Year gets 1999.

int year = moment.Year;

 

// Month gets 1 (January).

int month = moment.Month;

 

// Day gets 13.

int day = moment.Day;

 

// Hour gets 3.

int hour = moment.Hour;

 

// Minute gets 57.

int minute = moment.Minute;

 

// Second gets 32.

int second = moment.Second;

 

// Millisecond gets 11.

int millisecond = moment.Millisecond;

Basic .Net Layout

https://www.tutorialspoint.com/asp.net/asp.net_calenders.htm

 

<!-- directives -->

<% @Page Language="C#" %>

 

<!-- code section -->

<script runat="server">

 

   private void convertoupper(object sender, EventArgs e)

   {

      string str = mytext.Value;

      changed_text.InnerHtml = str.ToUpper();

   }

</script>

 

<!-- Layout -->

<html>

   <head>

      <title> Change to Upper Case </title>

   </head>

  

   <body>

      <h3> Conversion to Upper Case </h3>

     

      <form runat="server">

         <input runat="server" id="mytext" type="text" />

         <input runat="server" id="button1" type="submit" value="Enter..." OnServerClick="convertoupper"/>

        

         <hr />

         <h3> Results: </h3>

         <span runat="server" id="changed_text" />

      </form>

     

   </body>

  

</html>

Selecting a date and displaying it in a calendar

https://www.tutorialspoint.com/asp.net/asp.net_calenders.htm

 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="calendardemo._Default" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml" >

 

   <head runat="server">

      <title>

         Untitled Page

      </title>

   </head>

  

   <body>

      <form id="form1" runat="server">

     

         <div>

            <h3> Your Birthday:</h3>

            <asp:Calendar ID="Calendar1" runat="server  SelectionMode="DayWeekMonth" onselectionchanged="Calendar1_SelectionChanged">

            </asp:Calendar>

         </div>

        

         <p>Todays date is: 

            <asp:Label ID="lblday" runat="server"></asp:Label>

         </p>

        

         <p>Your Birthday is: 

            <asp:Label ID="lblbday" runat="server"></asp:Label>

         </p>

        

      </form>

   </body>

</html>

Retrieve data through a database

https://www.tutorialspoint.com/asp.net/asp.net_database_access.htm

 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="dataaccess.aspx.cs"

   Inherits="datacaching.WebForm1" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml" >

 

   <head runat="server">

      <title>

         Untitled Page

      </title>

   </head>

  

   <body>

      <form id="form1" runat="server">

         <div>

        

            <asp:SqlDataSource ID="SqlDataSource1" runat="server"

               ConnectionString= "<%$   ConnectionStrings:ASPDotNetStepByStepConnectionString%>"

               ProviderName= "<%$ ConnectionStrings:

                  ASPDotNetStepByStepConnectionString.ProviderName %>"

               SelectCommand="SELECT [Title], [AuthorLastName],

                  [AuthorFirstName], [Topic] FROM [DotNetReferences]">

            </asp:SqlDataSource>

           

            <asp:GridView ID="GridView1" runat="server"

               AutoGenerateColumns="False" CellPadding="4"

               DataSourceID="SqlDataSource1" ForeColor="#333333"

               GridLines="None">

               <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />

           

               <Columns>

                  <asp:BoundField DataField="Title" HeaderText="Title"

                     SortExpression="Title" />

                  <asp:BoundField DataField="AuthorLastName"

                     HeaderText="AuthorLastName" SortExpression="AuthorLastName" />

                  <asp:BoundField DataField="AuthorFirstName"

                     HeaderText="AuthorFirstName" SortExpression="AuthorFirstName" />

                  <asp:BoundField DataField="Topic"

                     HeaderText="Topic" SortExpression="Topic" />

               </Columns>

               <FooterStyle BackColor="#5D7B9D"

                  Font-Bold="True" ForeColor="White" />

               <PagerStyle BackColor="#284775"

                  ForeColor="White" HorizontalAlign="Center" />

               <SelectedRowStyle BackColor="#E2DED6"

                  Font-Bold="True" ForeColor="#333333" />

               <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" 

                  ForeColor="White" />

               <EditRowStyle BackColor="#999999" />

               <AlternatingRowStyle BackColor="White" ForeColor="#284775" />

            </asp:GridView>

         </div>

      </form>

   </body>

</html>

bottom of page