日期:2014-05-20  浏览次数:20882 次

script +<%#%> 的调用问题,哪位会
<script   type= "text/jscript "   language= "jscript ">
  function   singout(m_id)
  {
  var   aa= "Default2.aspx?index= "+m_id;
  ducoment.write(aa);
  }
  </script>


<body>
<table>
<tr>
<td>
<a   herf= <script   type= "text/jscript "> singout( <%#DataBinder.Eval(Container.DataItem,   "id "%> );> sss </a> </script>     //这行不行
</td>
</tr>
</table>

</body>

我给sss弄个连接,点一下就跳到Default2.aspx?index=N       N是从id中取的。我上面写的老是不成功,请哪为帮我写一个类似的,谢谢了,实现上面的调用

------解决方案--------------------
<%# DataBinder.Eval (Container.DataItem, "ID ") %>
------解决方案--------------------
<%#
DataBinder.Eval ...这样的语法
只能用于 数据绑定 控件下

这里你需要

<%= YourID%>

YourID 在.cs中 定义为类变量 protect string YourID = string.Empty;

在程序块中获取值...
------解决方案--------------------
<table>
<tr>
<td>
<a herf "javascript:singout( <%# DataBinder.Eval (Container.DataItem, "ID ") %> ); "> sss </a> </td>
</tr>
</table>

<script type= "text/jscript " language= "jscript ">
function singout(m_id)
{
var aa= "Default2.aspx?index= "+m_id;
//ducoment.write(aa);
window.location.replace(aa);

}
</script>

------解决方案--------------------
你的写法太费劲了,你的ID从哪里来呢?
干吗不直接用HyperLink控件呢。
------解决方案--------------------
.NET几乎所有客户端的web控件都是帮你写了HTML,HyperLink最后也是在网页里搞了一些类似的脚本和html代码
------解决方案--------------------
直接用C#代码实现