Set width in javascript.

2 posts, 0 answers
  1. Ben
    Ben avatar
    31 posts
    Member since:
    Feb 2013

    Posted 05 Nov 2013 Link to this post

    There is a radtextbox and a radsearchbox in my aspx page. The Javascript in this page has a getOrder() in which I want to access the width of the textbox and set it to searchbox using style.width. The width of searchbox increases to the stipulated width but the lens symbol position remains unchanged. If I set width in markup it works, but not in JavaScript.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Nov 2013 Link to this post

    Hi Ben,

    Please have a look into the following code I tried for your scenario which works fine at my end. If you set the width using approach, then you should call the repaint() to render the style properly.

    <telerik:RadTextBox ID="RadTextBox1" runat="server" Width="400px">
    <br />
    <telerik:RadSearchBox ID="RadSearchBox1" runat="server">
    <br />
    <telerik:RadButton ID="RadButton1" runat="server" Text="Set Width to RadSearchBox" AutoPostBack="false"

    <script type="text/javascript">
        function setSearchBoxWidth(sender, args) {
            var radtextboxwidth = $find("<%= RadTextBox1.ClientID%>")._element.offsetWidth;
            var radsearchbox = $find("<%= RadSearchBox1.ClientID%>");
   = radtextboxwidth + "px";

  3. DevCraft R3 2016 release webinar banner
Back to Top