本文介绍了如何在页面加载时将javascript var绑定到标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

aspx页面

< head>

aspx page
<head>

<script language="Javascript">
function country() {
           var country = "HI";
           var hiddenControl = '<%= inpHide.ClientID %>';
           document.getElementById(hiddenControl).value = country;
       }
</script>



< / head>

< body>

< form id =form1runat =server>


</head>
<body>
<form id="form1" runat="server">

<asp:HiddenField ID="inpHide" runat="server" />
       <asp:Label ID="lblMsg" runat="server" />



< / form>

< / body>



代码落后




</form>
</body>

code behind

protected void Page_Load(object sender, EventArgs e)
    {
        lblMsg.Text = inpHide.Value;
    }

推荐答案

<body onload="bind()">





添加脚本如下



add script as follows

<script language="Javascript">
 function bind() {
var value = "value which you want to display"; document.getElementById(lblMsg).value = value; }
</script>



请检查并通知这是否解决了您的问题?


Please check and inform is this solve your problem or not?


这篇关于如何在页面加载时将javascript var绑定到标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 00:56