Today I am starting tutorial of basic asp .net web application development using c# scripting language. And I will show you how we can develop a very basic web application which will just use basic controls.
Open Visual Studio and click to file:
Now click on New and select web site :
You can also use short cut key Shift+Alt+N to create a new website:
Name the project and select C# as language for your project and select location by browsing location and click ok to start website project. In this example I name the project as HelloWorld.
As You can see after clicking ok there will be a document named Default.aspx in which there should be some text which is a website normal html tags like <html>, <head>, <title> and <body>.
There will be a <div> tag inside <form> tag. We have to put all the designing controls and html tags inside this <form> tag.
We can use <br /> fro new line .
In the example I use a static line,some labels (Server side control) and Textbox and a Button.
You can switch to design view to see how your website will look like by clicking on Design tab. Follow the picture.
Here is our design view look of our hello world website.
Now Double Click on the Button.
This will open the code view where will write server side code(Scripting).
Now we will write some code to print hello word text in the textbox and label. Follow the code in the picture.
public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
lblDynamicText.Text = “Hello World!, This is my first asp .Net website using c# as scripting language”;
protected void btnPrompt_Click(object sender, EventArgs e)
lblDynamicText.Text = txtMessage.Text;
Now we will run the project to see the result. To run the project we have to press F5.
Or we can also follow the menu Debug-Start Debugging.
First time when we will run the project i.e. debug the project, there will be a prompt to modify the web.config file to enable debugging.. We will press Ok to start debugging.
This is website source code for website design.
<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<title>Hello Word Website</title>
<form id=”form1″ runat=”server”>
Hello World using static text.
<asp:Label ID=”lblDynamicText” runat=”server” Text=”Label”></asp:Label>
<asp:TextBox ID=”txtMessage” placeholder=”Write here something and press Button” Width=”300px” runat=”server”></asp:TextBox>
<asp:Button ID=”btnPrompt” runat=”server” Text=”Button”
Here we can see result by putting anything in the TextBox and Clicking on the Button to see the result.
See some responses in the picture.
Enjoy the website and happy coding.
How useful was this post?
Click on a star to rate it!
Average rating / 5. Vote count:
We are sorry that this post was not useful for you!
Let us improve this post!
Thanks for your feedback!