ASP 如何能获取JS的值

ASP 如何能获取JS的值,第1张

asp是服务器端语言,不能获取js(客户端)语言。

JS自然也不能获取服务端语言。

JS获取链接中的字符是在客户端中的,当然链接中的字符也能以get方式传给服务端。

那么,想用asp来获取JS的数据,就只能用JS来传递给asp,一般是用ajax方法。也就是说,用post或get的方式来传递过来

第一,给你的linkbutton设置一个ClientID,ClientID就是前台ID

第二,link到了前台,也就是个a,就好比label到了前台就是个span,找到这个a就可以了

其实用什么后台语言(php,jsp,asp),其核心还是会回归到html(超文本标记语言),即服务端只是一个模板语言,只是方便后台人员的开发和填充数据,其最后还是会编译成html文本。所以当使用js获取值时,还是用回DOM接口来获取。

如:由asp:TextBox ID="sl",可通过slDom = documentgetElementById("sl")

纯HTML页面是不行的,

必须是动态页面,如ASP

在ASP里可以这样:

<script language="javascript">

var Str="<%=session("变量")%>"

switch(Str){

case "条件1":

//相应语句;

break;

case "条件2":

//相应语句;

break;

default:

//相应语句;

break;

}

</script>

这个是JS特效代码

<script>

var delta=015

var collection;

function floaters() {

thisitems = [];

thisaddItem = function(id,x,y,content)

{

documentwrite('<DIV id='+id+' style="Z-INDEX: 10; POSITION: absolute; width:55px; height:60px;left:'+(typeof(x)=='string'eval(x):x)+';top:'+(typeof(y)=='string'eval(y):y)+'">'+content+'</DIV>');

var newItem = {};

newItemobject = documentgetElementById(id);

newItemx = x;

newItemy = y;

thisitems[thisitemslength] = newItem;

}

thisplay = function()

{

collection = thisitems

setInterval('play()',10);

}

}

function play()

{

if(screenwidth<=800)

{

for(var i=0;i<collectionlength;i++)

{

collection[i]objectstyledisplay = 'none';

}

return;

}

for(var i=0;i<collectionlength;i++)

{

var followObj = collection[i]object;

var followObj_x = (typeof(collection[i]x)=='string'eval(collection[i]x):collection[i]x);

var followObj_y = (typeof(collection[i]y)=='string'eval(collection[i]y):collection[i]y);

if(followObjoffsetLeft!=(documentbodyscrollLeft+followObj_x)) {

var dx=(documentbodyscrollLeft+followObj_x-followObjoffsetLeft)delta;

dx=(dx>01:-1)Mathceil(Mathabs(dx));

followObjstyleleft=followObjoffsetLeft+dx;

}

if(followObjoffsetTop!=(documentbodyscrollTop+followObj_y)) {

var dy=(documentbodyscrollTop+followObj_y-followObjoffsetTop)delta;

dy=(dy>01:-1)Mathceil(Mathabs(dy));

followObjstyletop=followObjoffsetTop+dy;

}

followObjstyledisplay = '';

}

}

var theFloaters = new floaters();

theFloatersaddItem('followDiv1','documentbodyclientWidth-65',330,'<%=ss%>');

theFloatersplay();

</script>

给表单里添加个隐藏的input

在提交的时候把select的text给它

如:

var selectText = ffcartypeoptions[ffcartypeselected]text;

以上就是关于ASP 如何能获取JS的值全部的内容,包括:ASP 如何能获取JS的值、asp.net js获取listview中的子控件(linkbutton)的对象、怎么在js中获取读出asp:DataGrid控件的值等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9270192.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-26
下一篇2023-04-26

发表评论

登录后才能评论

评论列表(0条)

    保存