Click here to Skip to main content
15,914,074 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

namespace student
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void clicked(object sender, EventArgs e)
        {
            try
            {

                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["registrationconnectionString"].ConnectionString);
                con.Open();
                string insertQuery = "insert into customertable (User_name,Name,Gender,Adress,City,State,Pin_code,mobile_no,Emali_id,User_id,Password) values (@User_name,@Name,@Gender,@Adress,@City,@State,@Pin_code,@mobile_no,@Emali_id,@User_id,@Password)";
                SqlCommand com = new SqlCommand(insertQuery, con);
                com.Parameters.AddWithValue("@User_name", TextBoxusername.Text);
                com.Parameters.AddWithValue("@Name",TextBoxname);
                com.Parameters.AddWithValue("@Gender",RadioButtongender.Checked.ToString());
                com.Parameters.AddWithValue("@Adress",TextBoxadress.Text);
                com.Parameters.AddWithValue("@City",DropDownListcity.SelectedItem.ToString());
                com.Parameters.AddWithValue("@State",DropDownListstate.SelectedItem.ToString());
                com.Parameters.AddWithValue("@Pin_code",TextBoxpincode.Text);
                com.Parameters.AddWithValue("@mobile_no",TextBoxmobno);
                com.Parameters.AddWithValue("@Emali_id",TextBoxemail);
                com.Parameters.AddWithValue("@User_id",TextBoxuserid);
                com.Parameters.AddWithValue("@Password",TextBoxpassword);
                com.ExecuteNonQuery();
                Response.Redirect("admin.aspx");
                Response.Write("registration succescesfull...");
                con.Close();
            }
            catch (Exception ex)
            {
                Response.Write("error:" + ex.ToString());
            }

        }
    }
}
Posted
Comments
Thanks7872 24-May-14 1:18am    
Such issue happens when you copy paste code from some where. See your page's codebehind,see your namespace,see you class name, identify what inherits from where.

1 solution

Hi,

You get this type error a textbox with id 'TextBoxusername' is not exists on .aspx page. If you are confirm that it will be there then check .aspx.designer.cs that is partial class for web page code behind class and the 'TextBoxusername' property shuld be there.

So in short. Delete existing TextBoxusername from .aspx page and recreate it.

So this error reason can be

1. The textbox thats id is TextBoxusername does not exist on .aspx page.
2. Textbox id can be misspelled.
3. TextBox TextBoxusername property does not exist on designer .aspx.cs page.

Thanks
 
Share this answer
 
Comments
Member 10838588 23-May-14 23:32pm    
<%@ Page Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="regc.aspx.cs" Inherits="store_2.regc" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style type="text/css">
.style13
{
height: 23px;
text-align: right;
}
.style16
{
height: 23px;
width: 197px;
text-align: left;
}
.style17
{
width: 197px;
text-align: left;
color: #0000FF;
}
.style18
{
width: 342px;
}
.style20
{
height: 23px;
width: 342px;
}
.style24
{
text-align: right;
}
#Reset1
{
width: 65px;
}
.style25
{
width: 182px;
text-align: left;
color: #0000CC;
}
.style26
{
width: 180px;
text-align: left;
color: #0000FF;
}
.style27
{
width: 177px;
text-align: left;
color: #0000FF;
}
.style28
{
width: 325px;
}
.style29
{
width: 326px;
}
</style>

<asp:Content ID="Content5" runat="server"
contentplaceholderid="ContentPlaceHolder2">
<br />

<table style="width:100%; height: 441px;">
<tr>
<td class="style2">
<asp:HyperLink ID="HyperLink9" runat="server" NavigateUrl="~/about.aspx">Home
<br />

<asp:HyperLink ID="HyperLink2" runat="server"
NavigateUrl="~/regc.aspx">Registration
<br />
<asp:HyperLink ID="HyperLink4" runat="server" NavigateUrl="~/log.aspx">Log-in
<br />
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Product.aspx">Product
<br />

<asp:HyperLink ID="HyperLink3" runat="server">My Account
<br />
<asp:HyperLink ID="HyperLink5" runat="server" NavigateUrl="~/serc.aspx">Serch Product
<br />
<asp:HyperLink ID="HyperLink7" runat="server" NavigateUrl="~/Connectus.aspx">24x7
Customer Care
<br />
<asp:HyperLink ID="HyperLink8" runat="server">Sitemap
<br />
<asp:HyperLink ID="HyperLink6" runat="server" NavigateUrl="~/about.aspx">About

</td>
<td class="style3" align="center">
<br />
<br />
<table style="width:100%;">
<tr>
<td class="style25">
<asp:Label ID="Label12" runat="server" Text="User Name">
</td>
<td class="style28">
<asp:TextBox ID="TextBoxusername" runat="server">
</td>
<td class="style24">
 </td>
</tr>
<tr>
<td class="style25">
<asp:Label ID="Label1" runat="server" Text="Name">
</td>
<td class="style28">
<asp:TextBox ID="TextBoxname" runat="server">
</td>
<td class="style24">
<asp:RequiredF
Member 10838588 23-May-14 23:34pm    
its my aspx page TextBoxusername is there no miss splled
Peter Leow 24-May-14 0:51am    
The code behind page you showed us was
public partial class _Default
suggested that your aspx page is default.aspx

But the aspx that you showed us indicated that
CodeBehind="regc.aspx.cs"
suggest that the aspx page is regc.aspx

which is which???
Member 10838588 24-May-14 1:44am    
sry i can not understand........can u explain plz........

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900