Can't change text on button via javascript.

8 posts, 0 answers
  1. Christopher Bishop
    Christopher Bishop avatar
    50 posts
    Member since:
    May 2008

    Posted 23 Nov 2008 Link to this post

    document.getElementById('testbutton').value = "fred";

    does not work on buttons?

    in html
    <input id="testbutton" style="text-align: left;width:74px;" type="button" value="My Test Button" />

    in javascript
    document.getElementById('testbutton').value = "fred";

    Does not change the text on the button, remove the formdecorator and it works fine...

    Any ideas?
  2. Christopher Bishop
    Christopher Bishop avatar
    50 posts
    Member since:
    May 2008

    Posted 23 Nov 2008 Link to this post

    I sure hope there is a function I can call instead of this

    document.getElementById(

    'Skinnedtestbutton').innerHTML = '<SPAN class="radfdOuterSpan"><SPAN class="radfdInnerSpan">Hello World</span></span>';

     

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Martin
    Admin
    Martin avatar
    585 posts

    Posted 24 Nov 2008 Link to this post

    Hello Christopher Bishop,

    Try the following function, I believe it will work for you:

    function

     

    changeText(SkinnedBtnId, NewText)
    {
        var
    button = document.getElementById(SkinnedBtnId).childNodes[0];
        button.childNodes[0].innerHTML = NewText;
    }

     

    Regards,
    Martin Ivanov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Backtell
    Backtell avatar
    5 posts
    Member since:
    May 2007

    Posted 03 Jan 2009 Link to this post

    This doesn't seem to work for me, especially on a ASP.NET button. Do you have any other suggestions? The first childNodes returns 'undefined'.
  6. Martin
    Admin
    Martin avatar
    585 posts

    Posted 05 Jan 2009 Link to this post

    Hello Backtell,

    It is strange why this does not work for you. Is it possible that you send me a sample project with your particular scenario and the script that changes the text of the button so I am able to help?

    All the best,
    Martin Ivanov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. Christopher Bishop
    Christopher Bishop avatar
    50 posts
    Member since:
    May 2008

    Posted 05 Jan 2009 Link to this post

    Whats the code look like that you are calling? Sounds like it isn't working because of a ID problem.
  8. Chris Castle
    Chris Castle avatar
    33 posts
    Member since:
    Mar 2006

    Posted 03 Feb 2009 Link to this post

    I am having this problem as well.  Can someone post a full example for an button that is runat="server" like below?

    <

     

    asp:Button ID="btnSave" runat="server" Text="Save" />

     

  9. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 04 Feb 2009 Link to this post

    Hello Chris,

    Here is now to do this:
        <form id="form1" runat="server"
            <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
     
            <script type="text/javascript"
                function changeText(button) 
                { 
                    var decoratedbutton = "_radfd_Skinned" + button.id;//allternative: var decoratedbutton = "_radfd_Skinned" + "<%= Button1.ClientID %>"; 
                    $get(decoratedbutton).childNodes[0].childNodes[0].innerHTML = "Text changed";             
                } 
            </script> 
     
            <telerik:RadFormDecorator ID="RadFormDecorator1" Visible="true" DecoratedControls="all" 
                runat="server" /> 
            <asp:Button ID="Button1" runat="server" Text="Test Button" OnClientClick="changeText(this); return false" /> 
        </form> 


    Best wishes,
    Georgi Tunev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017