比如:
<script>
function Test(xvalue)
{
return "<% =Ceshi(xValue) %>"value;
} </script>
c# 代码
Public string Ceshi(string str)
{
....略
}
如何把js中的参数 xValue 传递给C#呢???
<script>
function Test(xvalue)
{
return "<% =Ceshi(xValue) %>"value;
} </script>
c# 代码
Public string Ceshi(string str)
{
....略
}
如何把js中的参数 xValue 传递给C#呢???
请分清楚客户端和服务端
<% =Ceshi(xValue) %>里面的代码是在服务端执行的,执行时间是客户端页面加载之前,那时js根本还未执行,所以没有js变量
http://bbs.csdn.net/topics/390336339
//传递数据data
$.post('../**.cs', { Data:data }, function (result) {
if (!result.Success) {
alert("出错")
} else {
alert("ok");
}
}, 'json');
string data = context.Request.QueryString["Data"];
提供参考...
示例:http://www.cnblogs.com/lexus/archive/2007/11/29/977281.html