C#.asp页面显示传输
就是想把代码的内容显示在第三个div里面
各位我是新手,说理论我也写不出来,
麻烦写出来代码了我才知道.
<body>
<form id="form1" runat="server">
<div>
123
</div>
<div>
456
</div>
<div>
这个DIV是显示内容,但是不会
</div>
</form>
</body>
namespace FM
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string connectionString = ConfigurationManager.ConnectionStrings["Projector"].ConnectionString;
SqlConnection con = new SqlConnection(connectionString);
con.Open();
SqlCommand comm = new SqlCommand("select * from ProjectorFM", con);
SqlDataReader read = comm.ExecuteReader();
while (read.Read())
{
Response.Write(read[1].ToString() + "<br>");
}
}
protected void Unnamed_Click(object sender, ImageClickEventArgs e)
{
}
protected void Unnamed_Click2(object sender, ImageClickEventArgs e)
{
}
}
}
插排尾僧人
11 years, 4 months ago
Answers
我简单的理解下,你是想吧读取出来的东西放到DIV里面显示出来是么,既然是ASP.NET就用一个控件吧:
<body>
<form id="form1" runat="server">
<div>
123
</div>
<div>
456
</div>
<div>
<asp:Literal ID="ltr_text" runat="server"></asp:Literal>
</div>
</form>
</body>
namespace FM
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string connectionString = ConfigurationManager.ConnectionStrings["Projector"].ConnectionString;
SqlConnection con = new SqlConnection(connectionString);
con.Open();
SqlCommand comm = new SqlCommand("select * from ProjectorFM", con);
SqlDataReader read = comm.ExecuteReader();
while (read.Read())
{
ltr_text.Text = read[1].ToString();
}
}
protected void Unnamed_Click(object sender, ImageClickEventArgs e)
{
}
protected void Unnamed_Click2(object sender, ImageClickEventArgs e)
{
}
}
}
lblbzz
answered 11 years, 4 months ago