ASP:代码
<asp:TextBox ID="TextBox1" runat="server" ReadOnly="true"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" ReadOnly="true"></asp:TextBox>
Run Code Online (Sandbox Code Playgroud)
C#:
[System.Web.Services.WebMethod]
public static Array LoadAssetAssignView() {
string sql = "SELECT Time,Inuse FROM table4";
using(SqlConnection Connection = new SqlConnection((@ "Data Source"))) {
using(SqlCommand myCommand = new SqlCommand(sql, Connection)) {
Connection.Open();
using(SqlDataReader myReader = myCommand.ExecuteReader()) {
DataTable dt = new DataTable();
dt.Load(myReader);
Connection.Close();
Num1 = textbox1.text; //Error(Can't access my asp control)
Num2 = textbox2.text;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
在我的Asp页面我涉及两个文本框我的要求.但在我的后端,我无法访问静态方法中的文本框.建议一些想法.答案而不是评论被赞赏.