如何访问服务器中的函数输出(在javascript中) [英] How to access output of a function (in javascript) in server

查看:90
本文介绍了如何访问服务器中的函数输出(在javascript中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我搜索但找不到正确的解决方案。



我创建一个usercontrol并在页面中添加3个实例。
在usercontrol中创建
a函数并指定标签的vaue

但是当我运行此页面时,usercontrol没有显示这个标签。

这是我的代码



  function  createResult(){

document .getElementById(' <%= lbResult.ClientID%> ;')。innerText = ' NEWVALUE';
}



 <   asp:标签    ID   =  lbPlace    runat   =  server    CssClass   =  Orng_Font_Color >  <   / asp:Label  >  







出了什么问题?



我尝试过:



访问服务器端javascript函数的输出。

解决方案

标签呈现为不包含在表单回发中的span元素,因此如果更改客户端的值,则不会保留该更改。在页面上放置一个asp:Hidden字段并更新隐藏字段和标签,隐藏字段将包含在回发中,您可以在服务器代码中读取该值。


Hi I search but not found right solution.

I create a usercontrol and add 3 instance of it in a page.
a function created in usercontrol and specify vaue of a label
but when i run this page,usercontrol not shown this lable.
this is my code

    function createResult() {

document.getElementById('<%=lbResult.ClientID %>').innerText='NEWVALUE';
}


<asp:Label ID="lbPlace" runat="server" CssClass="Orng_Font_Color"></asp:Label>




what is wrong?

What I have tried:

access to output of a javascript function in server side.

解决方案

Labels are rendered as span elements which are not included in form postbacks so if you change the value client-side that change won't be persisted. Put an asp:Hidden field on the page also and update the hidden field as well as the label, and the hidden field will be included in the postback and you can read that value in your server code.


这篇关于如何访问服务器中的函数输出(在javascript中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆