构建项目时出现错误
c#的新手。使用.NET Framework 4.5.2。的Visual Studio 2015年 我只是下面这个例子:构建项目时出现错误
http://csharp-video-tutorials.blogspot.com/2012/10/calling-stored-procedure-with-output.html 当我尝试“在浏览器中查看它”它给了我没有任何解释的错误:
我.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.Data.SqlClient;
using System.Configuration;
namespace adoDemo
{
public partial class WebForm3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
string SC = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(SC))
{
SqlCommand cmd = new SqlCommand("dbo.spAddEmployee", con);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Name", txtEmployeeName.Text);
cmd.Parameters.AddWithValue("@Gender", ddlGender.SelectedValue);
cmd.Parameters.AddWithValue("@Salary", txtSalary.Text);
SqlParameter outputParameter = new SqlParameter();
outputParameter.ParameterName = "@EmployeeID";
outputParameter.SqlDbType = System.Data.SqlDbType.Int;
outputParameter.Direction = System.Data.ParameterDirection.Output;
cmd.Parameters.Add(outputParameter);
con.Open();
cmd.ExecuteNonQuery();
string EmpID = outputParameter.Value.ToString();
lblMessage.text = "Employee ID = " + EmpID;
}
}
}
}
这里是我的aspx文件:这里的唯一的事情就是unrecognized tag prefix or device filter asp
如果我胡佛我的鼠标上asp
<!DOCTYPE html>
<table style="border: 1px solid black; font-family:Arial">
<tr>
<td>
Employee Name
</td>
<td>
<asp:TextBox ID="txtEmployeeName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Gender
</td>
<td>
<asp:DropDownList ID="ddlGender" runat="server">
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
Salary
</td>
<td>
<asp:TextBox ID="txtSalary" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="btnSubmit" runat="server" Text="Submit"
onclick="btnSubmit_Click" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lblMessage" runat="server"></asp:Label>
</td>
</tr>
</table>
在设计模式,它看起来是这样的:
在我的项目我有3个Web窗体,但我只用WebForm3
,那里只有警告 - 不是错误。
以下是错误输出:
在C#中,惯例是对性能与大写字母开头。
只需使用:
lblMessage.Text
我认为这个问题不值得得到你的名声在这里得到解答,expecially由人。大概你可以在评论 –
@ un-lucky - 完成同样的事 - 我同意这是一个基本的初学者问题,不太可能对其他人有用。但是,就像你一样,我很乐意帮助别人。我不明白为什么评论比答案更合适。我的理解是,评论是澄清问题,而不是答案。 –
对不起,这个简单的问题。非常感谢 – Oleg
'.text'应该是'.Text','C#'是区分大小写的 –