Change textbox style at runtime

4 posts, 0 answers
  1. Phaneendra
    Phaneendra avatar
    27 posts
    Member since:
    Jul 2011

    Posted 05 Jul 2012 Link to this post

    Hi,
    I have a Rad Textbox in the form at page load i added style of display none,
    now at rad combox selection change  at client event, i have to set style display block of that textbox.

    function pageLoad() {
           txt = $find("<%=txtFuelsNameSearch.ClientID  %>");
           alert(txt);
       }






    Thanks in advance.


    Regards
    Krishna
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Jul 2012 Link to this post

    Hi Phaneendra,

    Try the following Javascript to achieve your scenario.

    JS:
    function OnClientSelectedIndexChanged(sender, args)
     {
       var textbox = $find("<%=RadTextBox1.ClientID %>");
       textbox._element.style.display = "block";
     }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Phaneendra
    Phaneendra avatar
    27 posts
    Member since:
    Jul 2011

    Posted 05 Jul 2012 Link to this post

    HI Princy,

    Thanks for the speedy reply.l
    The above code didn't work out. 


    Regards
    Phaneendra
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Jul 2012 Link to this post

    Hi Phaneendra,

    Unfortunately I couldn't replicate the issue. Here is the full code that I tried which works as expected at my end.

    ASPX:
    <telerik:RadTextBox ID="RadTextBox1" runat="server" ></telerik:RadTextBox>
      <telerik:RadComboBox ID="RadComboBox1" runat="server" OnClientSelectedIndexChanged="OnClientSelectedIndexChanged" >
        <Items>
          ...............
        </Items>
    </telerik:RadComboBox>

    JS:
    <script type="text/javascript">
    function OnClientSelectedIndexChanged(sender, args)
     {
       var textbox = $find("<%=RadTextBox1.ClientID %>");
       textbox._element.style.display = "block";
     }
    function pageLoad()
     {
       var textbox = $find("<%=RadTextBox1.ClientID %>");
       textbox._element.style.display = "none";
     }
    </script>

    Hope this helps.

    Thanks,
    Princy.
Back to Top