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

RadNumericTextBox onKey up enable/disable dropdownlist

5 Answers 131 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Borislava
Top achievements
Rank 1
Borislava asked on 19 Dec 2013, 03:44 PM
<telerik:RadNumericTextBox ID="txtStuAdds" Width="70px" Value="0" DbValue='<%# Bind("StudentAdds") %>'
                                                      runat="server" Type="Number" NumberFormat-DecimalDigits="0" Onkeyup="txtStudAddValueChanged()" >
                                                  </telerik:RadNumericTextBox>
                                                                                             <asp:DropDownList runat="server" ID="ddlStuAddStatus" />
I have RadNumericTextBox how can I disable/enable dropdown based on a value entered? if textbox is empty or 0 enable drop down else disable.
<script type="text/javascript">
    function txtStudAddValueChanged(sender, eArgs) {
        var numericTextBox = $find(sender.id);
        var value = numericTextBox.get_value();
        alert(value);
    }
I have the following script but it failed on var numericTextBox = $find(sender.id);

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Dec 2013, 02:57 AM
Hi Borislava,

Please try the following JavaScript to access the RadNumericTextBox in 'txtStudAddValueChanged' event.

JavaScript:
<script type="text/javascript">
    function txtStudAddValueChanged() {
        var numericTextBox = $find("<%=txtStuAdds.ClientID %>");
        var value = numericTextBox.get_value();
        alert(value);
    }
</script>

Let me know if you have any concern.
Thanks,
Shinu.

0
Borislava
Top achievements
Rank 1
answered on 20 Dec 2013, 12:38 PM
Getting a complier ex:
BC30451: 'txtStuAdds' is not declared. It may be inaccessible due to its protection level.

NumericTextBox inside raggrid edit template.
0
Shinu
Top achievements
Rank 2
answered on 21 Dec 2013, 03:14 AM
Hi Borislava,

Please try the following code snippet to access the value in the RadNumericTextBox on 'txtStudAddValueChanged event.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" OnItemDataBound="grid1_ItemDataBound"
    AutoGenerateEditColumn="true">
    <MasterTableView>
        <Columns>
            <telerik:GridTemplateColumn>
                <EditItemTemplate>
                    <telerik:RadNumericTextBox ID="txtStuAdds" Width="70px" Value="0" runat="server"
                        Type="Number" NumberFormat-DecimalDigits="0" Onkeyup="txtStudAddValueChanged(this)"
                        DbValue='<%# Bind("OrderID") %>'>
                    </telerik:RadNumericTextBox>
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

JavaScript:
<script type="text/javascript">
    function txtStudAddValueChanged(sender) {
        alert(sender.control.get_value());
    }
</script>

Hope this will helps you.
Thanks,
Shinu.
0
Borislava
Top achievements
Rank 1
answered on 26 Dec 2013, 01:31 PM
Now I am able to  get value but it's 1 value behind.
So if I enter 2 and 3 only 2 will show up .
Also how can I find a dropdownlist in order to disable based on value?
0
Shinu
Top achievements
Rank 2
answered on 27 Dec 2013, 02:52 AM
Hi Borislava,

Please have a look into the sample code snippet which works fine at my end.

ASPX:
<asp:DropDownList runat="server" ID="ddlStuAddStatus" />
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" OnItemDataBound="grid1_ItemDataBound"
    AutoGenerateEditColumn="true">
    <MasterTableView>
        <Columns>
            <telerik:GridTemplateColumn>
                <EditItemTemplate>
                    <telerik:RadNumericTextBox ID="txtStuAdds" Width="70px" Value="0" runat="server"
                        Type="Number" NumberFormat-DecimalDigits="0" ClientEvents-OnKeyPress="txtStudAddValueChanged"
                        DbValue='<%# Bind("OrderID") %>'>
                    </telerik:RadNumericTextBox>
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

JavaScript:
<script type="text/javascript">
    function txtStudAddValueChanged(sender, args) {
        var dropdownlist = document.getElementById("ddlStuAddStatus");
        if (args.get_keyCharacter() == " " || args.get_keyCharacter() == "0") {
            dropdownlist.disabled = true;
        }
        else
            dropdownlist.disabled = false;
        alert(args.get_keyCharacter());
    }
</script>

Let me know if you have any concern.
Thanks,
Shinu.
Tags
General Discussions
Asked by
Borislava
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Borislava
Top achievements
Rank 1
Share this question
or