Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi,

I've seen many posts about people trying to change the text via javascript after a linklabel was clicked but I cant seem to find one that helps me.

please look at my code below and assist where possible. The texts stays the same no matter what I try.

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="TestApp._Default" %>
 

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<script type = "text/javascript">
    function DisableButton() {
        document.getElementById('<%= SubmitButton.ClientID %>').InnerText = 'hidden';
        document.getElementById('<%= SubmitButton.ClientID %>').Text = 'text';
        document.getElementById('<%= SubmitButton.ClientID %>').InnerHTML = 'html';
        document.getElementById('<%= SubmitButton.ClientID %>').value = 'val';
    }
 
</script>
    <h2>
        Welcome to ASP.NET!
    </h2>
    <p>
                                <asp:LinkButton ID="SubmitButton" runat = "server" onclientclick="DisableButton()" >
                                    Click
                                </asp:LinkButton>
    </p>
 

Posted 3-Aug-12 6:45am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,

Try innerText/innerHTML instead of InnerText/InnerHTML.

Or try this: http://www.permadi.com/tutorial/jsInnerHTMLDOM/index.html[^]

Hope it helps.
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi Popstarr
have you tried to coding over codebehind?
i mean

Protected Sub SubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitButton.Click
       Me.SubmitButton.Text = "TextChanged"
   End Sub

try this
i hope this way help you.

Regards
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 350
1 Sergey Alexandrovich Kryukov 133
2 Sebastiaan Meijerink 105
3 Rana Waqas 100
4 Abhinav S 95
0 Sergey Alexandrovich Kryukov 6,558
1 OriginalGriff 6,268
2 Peter Leow 2,534
3 Abhinav S 2,344
4 Maciej Los 2,297


Advertise | Privacy | Mobile
Web04 | 2.8.150414.1 | Last Updated 3 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100