Developing first ASP.NET web site

Strat[menu]-> Run-> devenv -> opens Visual studio if installed
then,
File[menu]-> New-> Website-> select visual C# or visual basic(VB) from the installed templates-> select ASP.NET Empty website ->web location-> name -> click on OK


 Web location:

File System: Uses ASP.NET development server as web server.
Advantages:
  • No additional installations or configurations are required while using file system as web location.
Limitations:
  • Doesn't understand the network and hence the website cant be accessed across the systems connected with in the network.
  • We cannot use network related security features.
HTTP: Uses IIS (Internet information services) web server.
Advantages:
  • It is a very powerful web server which understands the network and network related features.
  • Supports many powerful features such as SMTP mail config, Bit-Rate Transmissions,Media services support etc.
Limitations:
  • IIS web server has installed and configured.
FTP: It is used to maintain the websites in specific systems based on the IP address of the system.

Before we start with our first website let us understand visual studio first.

Understanding VisualStudio:

Solution Explorer: (Ctrl + Alt+ L)
It maintains all the files that are supported by the application.

Tool Box: (Ctrl + Alt + X)
It maintains all the controls that can be used with in the application.

Properties Window: (F4)
It is used to set values of the controls.

Developing web form for website:

Right Click on the application in the solution explorer -> Select Add new item-> Give a meaningful name-> click on ADD.


The web from (Default.aspx) by default opens the source view. click on design button on bottom left for the design view.
  • Place a "Label" control from the tool box
  • select label ,open properties window to set following label properties
              ID : lblmsg
              Text: clear text.
  • place a "Button" control from the tool box
  • select Button ,open properties window to set following button properties
             ID : btnrefresh
             Text: Refresh
  • Double click any where in the page, Now new file Default.aspx.cs will open then write the following code.
 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack == false)
            lblmsg.Text = "Welcome to Memorize.NET Blog";
        else
            lblmsg.Text = "Welcome to ASP.NET";
    }
}

Explanation:
In the above program if the page is loaded for the first time Page.IsPostBack is false, so "Welcome to Memorize.NET Blog" will be  displayed ,when the refresh button is pressed the Page.IsPostBack is true so the "Welcome to ASP.NET" will be displayed.

No comments:

Post a Comment