ASP.NET without runat=server tag with asp.net C#

Category > ASP.NET || Published on : Thursday, October 17, 2019 || Views: 152 || ASP.NET without runat=“server” tag


Introduction

Here Pawan Kumar will explain how to ASP.NET without runat=server tag with asp.net C#

Description

Now I will explain How to ASP.NET without runat=server tag with asp.net C#

So follow the steps to learn ASP.NET without runat=server tag with asp.net C#


Step 1 - Create a asp.net website using Visual Studio 2019 or any other version of visual studio as you have installed on your system.


Step 2 - Add a new Webform C# into the website created in step 1


Step 3 - Write teh following codes in aspx page

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="NoServerControls.aspx.cs" Inherits="examples_3_NoServerControls" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>ASP.NET without runat=“server”</title>
</head>
    <body>
        <form method="post">
            <input type="text" name="tb1"/>
            <input type="submit" value="submit"/>
        </form>

        <h1>Hello  <%= echo %></h1>
   </body>
</html>

Step 4 -  Write the following codes in code behind file.

using System;

public partial class examples_3_NoServerControls : System.Web.UI.Page
{
    public string echo { get; set; }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Trivial example: skipping all validation checks
        //It's either a GET or POST end of day
        if (Request.RequestType == "POST")
        {
            //Do something with data, just echoing it here
            echo = Request["tb1"];
        }
    }
}

Now run the project using F5. After entering some text in textbox and then pressing submit button. It will print that textbox content onto the webpage and we will get ASP.NET without runat=“server” tag
 

Conclusion:

So, In this tutorial we have learned, ASP.NET without runat=server tag with asp.net C#

Download Source Codes