[英]how to get the value of client side variable in server side
I want to ask how to get the value of var title
: 我想问一下如何获取
var title
的值:
From this code : 从此代码:
protected void btnSubmit_Click(object sender, EventArgs e)
{
string script = "var title = $('.rsApt').attr('title');";
ClientScript.RegisterStartupScript(GetType(),"popup", script, true);
}
Thanks 谢谢
You'll have to post it back, the script runs on the client so its value needs to be passed to the server. 您必须将其重新发布,脚本在客户端上运行,因此需要将其值传递给服务器。
A common method is to insert var title into a textbox, which then gets POSTed to the server. 一种常见的方法是将var title插入文本框,然后将其发布到服务器。
you can: 您可以:
1- add a HiddenField to your page. 1-将HiddenField添加到您的页面。
2- get the value you want to store from your DOM element 2-从DOM元素中获取要存储的值
3- save your value to the HiddenField value. 3-将您的值保存到HiddenField值。
4- From your serverside code, read the HiddenField value. 4-从服务器端代码中,读取HiddenField值。
5- smile. 5-微笑。
6- Mark this post as (answer) :) 6-将此帖子标记为(答案):)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.