• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Email: info@dotnettec.com | Mobile: +91-8800268750

DotNetTec

  • Home
  • Tutorials
    • Programming Language
      • C#
      • JavaScript
    • .Net Development
      • .NET Framework
      • ASP.NET Web Forms
      • MVC Architecture
      • Web API
      • .NET Core Framework
    • Front End Frameworks
      • JavaScript
      • HTML
    • Cloud Computing
      • Microsoft Azure
    • Database
      • SQL Server
    • Google Maps API
    • RPA
      • Blue Prism
      • UiPath
  • How to
  • Knowledge Base
  • Shop

How to get html textbox value in ASP.Net

April 1, 2020 by Ravi Kumar Leave a Comment

In this blog post, you will learn about to get the value of input javascript and how to get Html textbox value in ASP.Net C# code behind aspx.cs page. Previously I have explained How to check if dropdown list contains value in C#, Facebook Style Homepage and Login Page Design using Html and CSS.

There are two ways we can access the HTML TextBox value in aspx code-behind:-

  • Using Request Form collection and name property.
  • Using runat = “server” property.

How to get Html textbox value in ASP.Net C#

The HTML <input> element is used to create interactive controls for web-based forms in order to accept data from the user. To get the value of textbox in javascript from Html the tag should have an attribute called [NAME]. Find the below source code:-

get value of input javascript

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="index" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>get value of input javascript</title>
</head>
<body>
    <form id="form1" runat="server">
        <h2>How to get html textbox value in asp.net</h2>
        <div>
            <input type="text" placeholder="First Name" name="_firstname" /><br />
            <input type="text" placeholder="Last Name" name="_lastname" /><br />
            <br />
            <asp:Button ID="btnShow" runat="server" Text="Show" OnClick="btnShow_Click" />

            <br />
            <br />
            <asp:Label ID="result" ForeColor="Red" runat="server"></asp:Label>
        </div>
    </form>
</body>
</html>

Default.aspx.cs

using System;
using System.Web.UI;
public partial class index : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnShow_Click(object sender, EventArgs e)
    {
        string firstName = Page.Request.Form["_firstname"].ToString();
        string lastname = Page.Request.Form["_lastname"].ToString();
        result.Text = firstName + " " + lastname;
    }
}

Download Source Code

Conclusion

I hope you liked this article on how to get html textbox value in asp.net code behind page. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.

Category iconASP.NET,  How to Tag iconget value of input javascript,  how to get html textbox value in asp.net

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Recent Posts

  • Google Maps Draw Polygon Get Coordinates
  • Check if point inside polygon Google Maps JavaScript
  • How to Create a Calendar Control in ASP.NET
  • Interview Etiquette Before, During and After
  • How to Attend Telephonic Interview Tips

Products

  • Online Shopping ASP.NET Project Source Code Online Shopping ASP.NET Project Source Code
    Rated 5.00 out of 5
    $69.00 $39.00
  • responsive-aspnet-mvc-grid-view ASP.NET MVC full Ajaxify and Bootstrap Grid with CRUD Operation
    Rated 4.67 out of 5
    $21.00 $9.00
  • eCommerce Website Source Code in ASP.NET eCommerce Website Source Code in ASP.NET $99.00
  • Hospital Management System Project ASP.Net Source Code
    Rated 5.00 out of 5
    $99.00
  • Whatsapp Bulk Message Sender Source Code WhatsApp Bulk Message Sender Source Code
    Rated 5.00 out of 5
    $69.00

Footer

DotNetTec

A platform for Software Developers and Architects. Learn new skills and apply them in real-life to build an end to end applications.

Sitemap

  • About
  • Blog
  • Shop
  • Contact
  • Privacy Policy

Expertise

  • Web Development
  • Custom Software Development
  • Web API Development
  • Google Maps APIs
  • Facebook
  • Instagram
  • Pinterest
  • Twitter
  • YouTube

Copyright © 2021 DotNetTec. All rights reserved. Return to top