首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

前台和后台传参有关问题

2012-03-31 
前台和后台传参问题前台script language javascript type text/javascript function divcenter(i)

前台和后台传参问题
前台


  <script language ="javascript" type ="text/javascript" >

   
  function divcenter(i) {
  var divId = document.getElementById('div1sss');
  document.getElementById('div1sss').innerHTML = i;
  document.getElementById('div1sss').style.display = "block";
  }
   
   
  </script>
   
   
  <div id="div1sss" style =" display :none ; position :absolute ; background-color :Yellow ;"></div> 






后台

  protected void Button2_Click(object sender, EventArgs e)
  {
  SqlDataBase Sql1 = new SqlDataBase();
  Sql1.Open();

  string strlinshi = string.Format("select neirong from JM_TB where id='{0}'",dex8 );
  SqlDataAdapter myapter = new SqlDataAdapter(strlinshi, SqlDataBase.Cn);
  DataSet ds = new DataSet();
  myapter.Fill(ds);
  if (ds.Tables[0].Rows.Count == 0)
  {
// Label1.Text = "无内容显示";
 // Label1.Visible = true;
  Page.RegisterStartupScript("", "<script>divcenter('无内容');</script>");
  }
  else
  {
  string f = ds.Tables[0].Rows[0][0].ToString();
  Sql1.Close();
   
  Page.RegisterStartupScript("", "<script> divcenter('f');</script>");
// Label1.Text = f;
// Label1.Visible = true;
  }
  }





我是在GRIDVIEW的rowcommand中调用的CLICK


  Page.RegisterStartupScript("", "<script> divcenter('f');</script>");
divcenter()里面随便写个内容就能成功 怎么让它显示我的变量F的内容啊?

[解决办法]
"<script> divcenter('"+f+"');</script>"
[解决办法]
Page.RegisterStartupScript("", "<script> divcenter(''+f+'');</script>");
试试看 不行就用双引号- - 我这边没环境不好测试

热点排行