Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8424267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:56:31+00:00 2026-06-10T03:56:31+00:00

I have a page with a with a form i when i fill the

  • 0

I have a page with a with a form i when i fill the form i want to access that form data in my c# codebehind file.

Register.aspx:

<%@ Page Title="Home" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="True" CodeBehind="Register.aspx.cs" Inherits="Informito._Default" %>
<div>
    <table class="style1">
    <tr>
        <td>Utilizador:</td>
        <td><asp:TextBox ID="Utilizador" name="Utilizador" runat="server"></asp:TextBox></td>
    </tr>
    <tr>
        <td>Password:</td>
        <td><asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox></td>
    </tr>
    </table>
</div>
<asp:Button ID="Button1" runat="server" Text="Registar" OnClick="Registar"/>

Register.aspx.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Security;
using System.Data.SqlClient;
using Informito.Admins;

namespace Informito
{
    public partial class _Default : Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void Registar(object sender, EventArgs e)
        {
            string Username = Utilizador.Text; //Error here: Object reference not set to an instance of an object.
            string Password= Password.Text;
            RegisterUser(Username, Password, 1);
        }

    }
}

Register.aspx.designer.cs:

namespace Informito {


    public partial class _Default {

        protected global::System.Web.UI.WebControls.LoginView LoginView1;
        protected global::System.Web.UI.WebControls.TextBox Utilizador;
        protected global::System.Web.UI.WebControls.TextBox Password;
    }
}

What function i have to use to read from a asp.net textbox and pass it to by c# codebehind variable?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T03:56:32+00:00Added an answer on June 10, 2026 at 3:56 am

    UPDATE:

    You need to enclose your markup in <asp:Content></asp:Content> tags because you are using a master page.


    If you have used Visual Studio to generate your web project, then you can see Register.aspx.designer.cs which should have code like below. If you don’t then add it in the class (you can add it in Register.aspx.cs or Register.aspx.designer.cs).

    protected global::System.Web.UI.WebControls.TextBox Utilizador;
    

    Then you can use

    string UserName = Utilizador.Text;
    

    UPDATE:

    I just tried this and seems to work fine:

    Register.aspx.cs

    public void Registar(object sender, EventArgs e)
    {
        string Username = Utilizador.Text; 
        string PassWd = Password.Text;
        RegisterUser(Username, PassWd, 1);
    }
    

    Register.aspx.designer.cs

    public partial class _Default {
    
            protected global::System.Web.UI.WebControls.TextBox Utilizador;
            protected global::System.Web.UI.WebControls.Button Button1;
            protected global::System.Web.UI.WebControls.TextBox Password;
        }
    

    Register.aspx

    <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
        CodeBehind="Register.aspx.cs" Inherits="Informito._Default" %>
    
    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <div>
        <table class="style1">
        <tr>
            <td>Utilizador:</td>
            <td><asp:TextBox ID="Utilizador" name="Utilizador" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <td>Password:</td>
            <td><asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox></td>
        </tr>
        </table>
    </div>
    <asp:Button ID="Button1" runat="server" Text="Registar" OnClick="Registar"/>
    </asp:Content>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a contact page (contact.php) that sends a form (formsend.php) when people fill
I have a page that submits data to PayPal, through their standard form fields.(not
I have a form page in PHP that reads a DBF, and conditionally converts
I have a page with a form that is submittes via ajaxSubmit() (so, without
I have a page with a form on it that needs to post to
Basically I have a page named dvds.asp with a form that goes to action=process.asp
Heres the situation: I have a form that is spread across three pages. (Page
On my home page, I want a simple webpart that allow users to quickly
Hello i want to make a site that will have a registration page a
So I have a form that users fill out with some radio buttons. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.