Click here to Skip to main content
15,909,503 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<asp:LinkButton ID="lnkb" runat="server" Text="Link" OnClientClick="work();" />
<asp:HiddenField ID="hidlabel" runat="server" Value="I am old value" />

function work()
        {
            document.getElementById('<%=hidlabel.ClientID%>').value = "hello";
            alert(document.getElementById('<%=hidlabel.ClientID%>').value);
        }


The above code is working fine,But I need to set the LinkButton text to hidden value.
How to achive this task?
Posted

Try:
JavaScript
function work()
{
  // Link button text to hidden field value.
  document.getElementById('<%=hidlabel.ClientID%>').value = document.getElementById('<%=lnkb.ClientID%>').innerText;
}
 
Share this answer
 
v2
Comments
Toniyo Jackson 26-Apr-11 2:40am    
I think you misplaced. OP need to set the LinkButton text to hidden value.

Check my ans. :)
Sandeep Mewara 26-Apr-11 3:02am    
Oh! the opposite... missed it while writing. :)
Toniyo Jackson 26-Apr-11 3:10am    
Yeah. :)
swathi6589 26-Apr-11 2:59am    
Thank you Sandeep
Try this,
function work()
        {
            document.getElementById('<%=hidlabel.ClientID%>').value = "hello";
            alert(document.getElementById('<%=hidlabel.ClientID%>').value);

document.getElementById('<%=hidlabel.ClientID%>').value= document.getElementById('<%=lnkb.ClientID%>').innerText;
        }
 
Share this answer
 
v4
Comments
swathi6589 26-Apr-11 2:58am    
Thanku Toniyo

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