如何在母版页的javascript中获取超链接的值 [英] how to get the value of a hyperlink in javascript in masterpage

查看:68
本文介绍了如何在母版页的javascript中获取超链接的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当用户单击滞后时,我正在使用母版页.我必须在javascript中显示一个确认消息框.在母版页中,超链接文本将根据语言进行更改,因此我必须以其语言显示确认消息.

我的代码是这样的:

我的母版页:

< asp:HyperLink ID ="idlang" runat ="server" NavigateUrl =" Text ="Germany">

Hi,

i am using a master page, when the user click on lagout. i have to display a confirm message box in javascript. in master page the hyperlink text will be changed based on the language, so i have to display the confirm message in their language.

My code is like this:

im master page:

<asp:HyperLink ID="idlang" runat="server" NavigateUrl="" Text="Germany">

asp:LinkButton ID="btnLogout" CausesValidation="false" runat="server" Text="Logout"
                                    OnClientClick="confirmDelete();" OnClick="btnLogout_Click"></asp:LinkButton>




我的js:




my js:

function confirmDelete() {
           
                       var lang = document.getElementById('idlang');
                      if (lang.value == 'Germany') {

                           return confirm('GErmany message');
                     } else {
                          return confirm('English');
                       }
                    

       }
   </script>



但是我没有在idlang值中得到任何值,它显示为null.

谁能帮忙这个



but i am not getting any value in idlang value, it shows null.

Can anyone help on this

推荐答案

尝试更改此行:

Try changing this line:

var lang = document.getElementById('idlang');



对此:



to this:

var lang = document.getElementById("<%= idlang.ClientID %>");



希望对您有所帮助:)



hope it helps :)


这篇关于如何在母版页的javascript中获取超链接的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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