Код: Выделить всё
"CS0103: The name 'TextBox' does not exist in the current context".
Код: Выделить всё
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Mail;
using System.Drawing;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.Text;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
con.Open();
}
protected void Register_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("insert into storedatabase values('"+TextBox2.Text+"')")
}
}
Код: Выделить всё
Я искал почти везде в Google, вот основные вещи, которые мне нужны. попробовал:
- с помощью потенциальных исправлений для преобразования TextBox2 в переменную
- проверил, есть ли в TextBox2 "runat="server" "
- проверил правописание
Любая помощь приветствуется. Спасибо!
Изменить:
Я создал новый проект (Aform), но проблема все еще сохраняется.
Вот весь Aform.aspx.cs:
< pre class="snippet-code-html lang-html Prettyprint-override">
Код: Выделить всё
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Mail;
using System.Drawing;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.Text;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
conn.Open();
}
protected void Register_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("insert into storedatabase values('" + firstNameTxt.Text + "')");
}
}
А вот Aform.aspx:
Код: Выделить всё
testWebPage
.auto-style2 {
width: 100%;
}
.auto-style3 {
height: 25px;
}
.auto-style4 {
width: 292px;
}
.auto-style5 {
height: 25px;
width: 292px;
}
textarea {
resize: none;
}
.auto-style6 {
height: 64px;
}
.auto-style7 {
margin-right: 0px;
}
.auto-style8 {
width: 292px;
height: 26px;
}
.auto-style9 {
height: 26px;
}
.auto-style10 {
width: 292px;
height: 23px;
}
.auto-style11 {
height: 23px;
}
testWebApp
First Name
Message
Код: Выделить всё
Aform.aspx.cs' is inside
Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/792 ... ng-a-few-t