This is a migrated thread and some comments may be shown as answers.

How to fix a div size after value changed RadNumericTextBox

1 Answer 81 Views
Input
This is a migrated thread and some comments may be shown as answers.
M
Top achievements
Rank 1
M asked on 23 Dec 2013, 05:09 PM

I've been using a RadNumericTextBox to fix a min and max values for sizing a div.

Control

<Telerik:RadNumericTextBox ID="txtHeight" runat="server" MinValue="0" MaxValue="128" NumberFormat-DecimalDigits="0" onchange="setHeight();"></Telerik:RadNumericTextBox>

JS function

function setHeight() {
    $("#div1").css("height", $("[id$=txtHeight]").val());
}

DIV

<div id="div1" style="border:1px solid black;"></div>

Everything works well, but when I input the value of 500 inside the txtHeight then lost the focus, the RAD control fix the max value to 128 but the div has been already change the height to 500px and it's not refreshed. I put a button to refresh the value of the div but what I really want is to set it in the change or blur client side event of the textbox. If not, it could be seen as a bug. So how can I do to set the div size after the RADControl does the change value to maximum value set?

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 25 Dec 2013, 08:15 AM
Hello,

You need to use the client-side events provided by the RadNumericTextBox:
<script type="text/javascript">
    //Put your JavaScript code here.
    function valueChanged(sender, args) {
        if (args.get_newValue() != '') {
            $("#div1").height(args.get_newValue());
        }
    }
</script>
<telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" MinValue="0" MaxValue="128">
    <NumberFormat DecimalDigits="0" />
    <ClientEvents OnValueChanged="valueChanged" />
</telerik:RadNumericTextBox>
<br />
<br />
<div id="div1" style="border: 1px solid black; background-color: lightblue; width: 128px; height: 128px"></div>

Hope this helps. Please copy this mark-up to your page and let me know about the result.

Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Input
Asked by
M
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or