A Place For My Thoughts, Technical Activities & Dev Stuff

admin-ajax (3)

Develop an ASP.NET Web App in C#

by

To Create an ASP.NET Web Page;

Let’s Create an ASP.NET Web Project in Microsoft Visual Studio;

In the template Selection, check the Empty Project And let the remaining thing uncheck and chick OK;

Microsoft Visual Studio will create some files for you in Solution Explorer;

Now Let’s create a Web Form in the Project. Go to add file and create a Web From with name Default;

Now you’ll get a Default state of Web Form Page;

Here you will notice that some of the HTML elements have “runat=”server”” attribute. That means that these elements will be send to the server and process there and HTML will be send back to Browser.

So, to show some output over the webpage, add view items over that page.

Go to Design View of the Page. From Toolbox, Drag TextBox, Button and Label into the div tag of the Default Page;

And when you go to the source code, then you will see that Microsoft Visual Studio will generate all the markup code for you in source control;

You will see that markups will be stay with asp prefix. That means they are part of ASP namespeace. And they all have runat=”server”, so all will be processed at server level.

Now let’s add some event handler. For that, in the properties windows, click on the lightning bolt icon. That gives you the list of events that can happened with that control;

To Generate some locial code in C#, lets double click in the text block next to event name. You’ll get into the logical file of C# and Event handler method will be generate for you;

So add some code to handle the event;

string value = TextBox1.Text;

Label1.Text = value;

Now to run the ASP application, you will need a server and Visual Studio include a development server that will fire up automatically. So when we run the application, it will open the app in Browser;

Now Lets check our C# code. Type something in Text Block and hit the button. The Event Handler of Button will call. The value will read from Text Block and the message will display over Label;

When the user clicks the button, the value that they typed in their form control is send back to the server and new HTML is generated and send back to the browser…

You design your interface and code you C# by using very similar architecture to other platforms instead of using XAML. By using simple HTML tags and C# logic you easily perform your tasks.

Warning: Invalid argument supplied for foreach() in D:\home\site\wwwroot\wp-includes\translations.php on line 1445

3 Comments

Leave a Reply

Your email address will not be published.

*

Latest from Microsoft Visual C#.

Go to Top