首页 新闻 赞助 找找看

滚动新闻的链接点击后没反应

0
[待解决问题]

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>&nbsp;&nbsp;"+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();

   }

  } 
}

 

请问上面红色部分的代码应该怎样写才能传值到下个页面,并显示

心语2012的主页 心语2012 | 菜鸟二级 | 园豆:216
提问于:2012-09-28 22:07
< >
分享
所有回答(2)
0

这样子写不可以吗?你通过这样的方式生成的a,可以在页面上右击审查元素来看看实际的情况(chrome游览器)

chenping2008 | 园豆:9836 (大侠五级) | 2012-09-29 09:57
0

 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>&nbsp;&nbsp;"+sqlRdr.GetValue(2).ToString()+"</font><br><br>";

    }

改为直接的链接后,不用js又可以使用了

心语2012 | 园豆:216 (菜鸟二级) | 2012-10-15 10:52
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册