Click here to Skip to main content
15,887,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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">

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



my js:

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

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

       }
   </script>


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

Can anyone help on this
Posted
Updated 9-Mar-12 19:08pm
v2

1 solution

Try changing this line:

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


to this:

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


hope it helps :)
 
Share this answer
 
Comments
inayat basha 10-Mar-12 1:22am    
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

This error message is comming
Uday P.Singh 10-Mar-12 1:31am    
Refer this for error.
inayat basha 10-Mar-12 1:51am    
yes i checked with this also, same error is comming

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900