using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data;
using System.Data.SqlClient;
public partial class userControll_WebUserControl : System.Web.UI.UserControl
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
SqlConnection myCon = new SqlConnection("Data Source=.;Initial Catalog=ABIS_BASE;Persist Security Info=True;User ID=wangchenyu;Password=wcy054411");
string strSql = "SELECT * FROM t_sys_Menu ";
string strScrolling = "";
HtmlTableCell cellScrolling = new HtmlTableCell();
SqlCommand myComd = new SqlCommand(strSql,myCon);
SqlDataReader sqlRdr;
try
{
myCon.Open();
sqlRdr = myComd.ExecuteReader();
strScrolling = "<Marquee OnMouseOver='this.stop();' OnMouseOut='this.start();' direction='up' scrollamount='2' bgcolor='#000000' width='40%'>";
while(sqlRdr.Read())
{
strScrolling = strScrolling + "<a href='#' OnClick="+"javascript:window.open('newsDetail.aspx?NewsId="+sqlRdr.GetValue(0)+"','NewsDetail','width=400,height=400;toolbar=no;');"+"><font face='verdana' size='2' color='#ffffff'>"+ sqlRdr.GetValue(1) +"</a> "+sqlRdr.GetValue(2).ToString()+"</font><br><br>";
}
strScrolling = strScrolling +"</Marquee>";
sqlRdr.Close();
cellScrolling.InnerHtml = strScrolling;
rowScrolling.Cells.Add(cellScrolling);
}
catch(Exception msg)
{
Response.Write(msg.Message);
}
finally
{
//close sql connection
myCon.Close();
}
}
}
请问上面红色部分的代码应该怎样写才能传值到下个页面,并显示
这样子写不可以吗?你通过这样的方式生成的a,可以在页面上右击审查元素来看看实际的情况(chrome游览器)
while(sqlRdr.Read())
{
strScrolling = strScrolling + "<a href='www.baidu.com' width=400,height=400;toolbar=no;');"+"><font face='verdana' size='2' color='#ffffff'>"+ sqlRdr.GetValue(1) +"</a> "+sqlRdr.GetValue(2).ToString()+"</font><br><br>";
}
改为直接的链接后,不用js又可以使用了