Click here to Skip to main content
13,090,730 members (43,647 online)
Rate this:
 
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 5: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
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 3 Aug 2012
Copyright © CodeProject, 1999-2017
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