弱弱的问:怎么样获得一个网页的某个控件的值? 我是一个新手,原来是做CS的,现在有个需要就是在某个网页上输入一个条件然后查询后返回一个值,举例如下:查询某个学生的成绩,我在一个网页上输入该学生学号,则返回该学生成绩,请问这个成绩如何获得?最好有个实例,谢谢大家! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 页面<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>无标题页</title></head><body> <form id="form1" runat="server"> <div> <asp:TextBox ID="txtID" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /><br /> <asp:Label ID="lblName" runat="server" Text="Label"></asp:Label></div> </form></body></html>后台using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string connectionString = "Data Source=.;database=Northwind;uid=sa;pwd=sa"; SqlConnection con = new SqlConnection(connectionString); con.Open(); string sql="select * from bb where id="+txtID.Text; SqlCommand com = new SqlCommand(sql, con); SqlDataReader dr = com.ExecuteReader(); while (dr.Read()) { this.lblName.Text = dr["jh"].ToString(); } dr.Close(); }}简单写了一个没有用三层!! this.textBox.textOrthis.DropdownList.selectValueor ............... 请教下,关于书籍 关于treeview的一个问题 asp.net 如何截取 路径 如何避免大批量垃圾信息的发布? .net 如何转成jsp 网站开发时用了微软的AjaxToolkit,发布上传后出错 关于外部链接绑定控件上的问题! 怎么让LABEL控件的文字坚着显示呀?急! 如何清除页面的viewstate? 关于datagrid内的checkbox的问题 删除Excel列问题 ADO.NET工厂模式下数据删除错误
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtID" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /><br />
<asp:Label ID="lblName" runat="server" Text="Label"></asp:Label></div>
</form>
</body>
</html>
后台
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
string connectionString = "Data Source=.;database=Northwind;uid=sa;pwd=sa";
SqlConnection con = new SqlConnection(connectionString);
con.Open();
string sql="select * from bb where id="+txtID.Text;
SqlCommand com = new SqlCommand(sql, con);
SqlDataReader dr = com.ExecuteReader();
while (dr.Read())
{
this.lblName.Text = dr["jh"].ToString();
}
dr.Close();
}
}
简单写了一个没有用三层!!
Or
this.DropdownList.selectValue
or
...............