javascript - 为什么不能从 javascript 更改 asp.net 中的标签文本?

标签 javascript asp.net

这是 html 代码:

<table align='right' >
<tr>
  <td><asp:Label ID="lblEmail" runat="server" Text=""></asp:Label></td> 
  <td > <div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark">
     </div></td>
</tr>
</table>

这是我的函数脚本:

<script>
        function onSignIn(googleUser) {
            var profile = googleUser.getBasicProfile();
             document.getElementById('lblEmail').InnerHTML = profile.getEmail();         
           // alert(profile.getEmail());

        };
    </script>

lblEmail 无法显示值,为什么?

我尝试使用警报,它显示电子邮件正常。

最佳答案

输入带有小写 i 的innerHTML:

<script>
       function onSignIn(googleUser) {
        var profile = googleUser.getBasicProfile();
         document.getElementById('lblEmail').innerHTML = profile.getEmail();         
       // alert(profile.getEmail());

    };
</script>

关于javascript - 为什么不能从 javascript 更改 asp.net 中的标签文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44197618/

相关文章:

javascript - 当子元素已知时,如何在 jQuery 中获取父元素?

javascript - 我可以使用 ng-repeat 并具有带有 Angular 分量的隔离范围吗?

javascript - 使用 javascript 在两行之间创建一个表行?

asp.net - IsPostback 在技术上是如何工作的?

.net - 无法加载文件或程序集 '' 或其依赖项之一。 API调用异常退出

javascript - window.print() - 不打开打印窗口

javascript - JSON 数据不会通过 jQuery getJSON() 显示

php - 未捕获的类型错误 : Object [object Object] has no method 'highcharts'

c# - 如何在 asp.net 中使用 System.Web.Caching?

jquery - 如何在 ASP.NET MVC 中为单词着色