how to add the style to the input box dynamically

3 posts, 1 answers
  1. lan
    lan avatar
    10 posts
    Member since:
    Jul 2012

    Posted 13 Oct 2010 Link to this post

    Hi Telerik,

    We use RadComboBox to let our customers to input/choose font family. The idea is when user finish the input/choose,  we try to set the input box font-family equals to what his input, so the user knows what exactly it looks like.

    We will use two functions on the client side: OnClientSelectedIndexChanged and OnClientTextChange

    but we don't know how to set the style in the client functions.

    Please help.

    Thanks in advance.

  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 14 Oct 2010 Link to this post

    Hello Lan,

    Try the following code snippet which shows how to set RadComboBox input box fontfamily style from client side.

    ASPX:
    <telerik:RadComboBox ID="RadComboBox1" runat="server"   
        OnClientSelectedIndexChanged="Changefontstyle"  AllowCustomText="True">
    </telerik:RadComboBox>

    Java Script:
    <script type="text/javascript">
        function Changefontstyle(sender, args) {
          var inputElement = sender.get_inputDomElement();
          inputElement.style.fontFamily = "Courier";//setting fontfamily style
       }
    </script>

    Thanks,
    Princy.
  3. lan
    lan avatar
    10 posts
    Member since:
    Jul 2012

    Posted 14 Oct 2010 Link to this post

    Thanks Princy!

    That's exactly what I am looking for.  I just changed a little bit in case other people need it.

    <script type="text/javascript">

        functionChangefontstyle(sender, args) {

          varinputElement = sender.get_inputDomElement();

          inputElement.style.fontFamily = sender._text;//setting fontfamily style

       }

    </script>

Back to Top