$find radcontrol is null

3 posts, 1 answers
  1. Daniel
    Daniel avatar
    35 posts
    Member since:
    Jan 2011

    Posted 06 Aug 2013 Link to this post

    Hi,

    i have a problem with $find.

    I have this function:

    function chkIfEmpty(parmtxt) {
     
        var rtxtBox = $find(parmtxt);
        var val = rtxtBox.get_element().value;
     
        if (!$.trim(val).length) {
            $('#imgaccept1').attr('style', 'display:none;');
            $('#imgexclamation1').attr('style', 'display:block;');
            $('#hfEingabeCheck').val('false')
        }
    }

    And i call it like this:

    <telerik:RadTextBox ID="rtxtVermittlerName" runat="server" Label="Name" LabelWidth="100px" Width="350px" Skin="MetroTouch" EmptyMessage="Mustermann" onblur="chkIfEmpty('<%= rtxtVermittlerName.ClientID %>')"></telerik:RadTextBox>

    But everytime "parmtxt" is null.
    if i write it directly like this: var rtxtBox = $find("<%= rtxtVermittlerName.ClientID %>");
    it works.

    What i'm doing wrong?
    Thanks for reading.
    Daniel
  2. Answer
    A2H
    A2H avatar
    177 posts
    Member since:
    Mar 2010

    Posted 06 Aug 2013 Link to this post

    Hello,

    The problem was that the client ID gets passed literally as '<%= rtxtVermittlerName.ClientID %>' instead of the actual client ID, hence  “$find(parmtxt)” could not get the object of RadTextBox.

    Please modify your code like given below to solve the issue.

    1) ASPX:

    <telerik:RadTextBox ID="rtxtVermittlerName" runat="server" Label="Name" LabelWidth="100px" Width="350px" Skin="MetroTouch" EmptyMessage="Test"
           onblur="chkIfEmpty(this)"></telerik:RadTextBox>

    2) Javascript

    function chkIfEmpty(parmtxt) {
               //var rtxtBox = $find(parmtxt);
               //var val = parmtxt.get_element().value;
               var val = parmtxt.value;
               alert(val);
               if (!$.trim(val).length) {
                   $('#imgaccept1').attr('style', 'display:none;');
                   $('#imgexclamation1').attr('style', 'display:block;');
                   $('#hfEingabeCheck').val('false')
               }
           }


    Thanks,
    A2H
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Daniel
    Daniel avatar
    35 posts
    Member since:
    Jan 2011

    Posted 07 Aug 2013 Link to this post

    That was very helpful.
    Thank you :)
Back to Top