$find fails in javascript for RadNumericTextBox on jquery Document.Ready in IE

2 posts, 0 answers
  1. Jonathan
    Jonathan avatar
    134 posts
    Member since:
    Sep 2007

    Posted 30 Jul 2013 Link to this post

    Hi,

     I need to disable some fields on the client side on page load that I will later enable via JavaScript.  Doing this from the server side is not supported so I'm doing this by calling a JavaScript function from the jquery document ready as in:
    $(document).ready(function() {
                                                            // Handler for .ready() called.
                                                            initialize();
                                                            //setVisibleMarkers();
                                                            alert("document.ready");
                                                            enableMailingLabelsButton();
                                                            EnableCustomTemplates();
                                                        });

    the enableMailingLabelsButton is as follows:

    function enableMailingLabelsButton()
    {
         
        var btnPrintMailingLabels = document.getElementById('<%=btnPrintMailingLabels.ClientID%>');
        var btnRefresh = document.getElementById('<%=btnRefresh.ClientID%>');
        var ddlMailingList = document.getElementById('<%=ddlMailingList.ClientID %>');
        var rdoSelectNew = document.getElementById('<%=rdoSelectNew.ClientID %>');
        var rdoSelectDefault = document.getElementById('<%=rdoSelectDefault.ClientID %>');
        var rdoSelectDateRange = document.getElementById('<%=rdoSelectDateRange.ClientID %>');
        var rdoPreviousDataSet = document.getElementById('<%=rdoPreviousDataSet.ClientID %>');
        var txt1ClickNumberToPrint = $find('<%= txt1ClickNumberToPrint.ClientID %>')
        var txtDateRangeNumberToPrint = $find('<%= txtDateRangeNumberToPrint.ClientID %>')
        var rdiStartDate = $find('<%= rdiStartDate.ClientID %>')
        var rdiEndDate = $find('<%= rdiEndDate.ClientID %>')
     
        if (rdoSelectNew.checked == true)
        {
            //alert(rdiStartDate);
            rdiStartDate.disable();
            rdiEndDate.disable();
            txt1ClickNumberToPrint.disable();
            txtDateRangeNumberToPrint.disable();
            ddlMailingList.disabled = true;
            btnPrintMailingLabels.disabled = true;
            btnRefresh.disabled = true;
        }
        else if (rdoSelectDefault.checked == true)
        {
            rdiStartDate.disable();
            rdiEndDate.disable();
            txt1ClickNumberToPrint.enable();
            txtDateRangeNumberToPrint.disable();
            ddlMailingList.disabled = true;
            btnRefresh.disabled = false;
            btnPrintMailingLabels.disabled = true;
        }
        else if (rdoSelectDateRange.checked == true)
        {
            rdiStartDate.enable();
            rdiEndDate.enable();
            txt1ClickNumberToPrint.disable();
            txtDateRangeNumberToPrint.enable();
            ddlMailingList.disabled = true;
            btnRefresh.disabled = false;
            btnPrintMailingLabels.disabled = true;
        }
        else if (rdoPreviousDataSet.checked == true)
        {
         
            rdiStartDate.disable();
            rdiEndDate.disable();
            txt1ClickNumberToPrint.disable();
            txtDateRangeNumberToPrint.disable();
            ddlMailingList.disabled = false;
            btnRefresh.disabled = false;
            if (ddlMailingList.selectedIndex >= 0 ) {
                //       alert("making labels active");
                btnPrintMailingLabels.disabled = false;
            }
            else {
                //       alert("making labels inactive");
                btnPrintMailingLabels.disabled = true;
            }
        }
    }

    The line var txt1ClickNumberToPrint = $find('<%= txt1ClickNumberToPrint.ClientID %>')  
    shows a null after execution 
    in the  txt1ClickNumberToPrint field, so when trying to disable this field the javascript throws an error on
    page load and stops executing only in IE 10 on first load.  once the page is loaded things work fine also
    Chrome does not have an issue at all.  I'd appreciate any help.  Here is the markup for that section.

    <fieldset style="width:100%;">
    <legend>Select Your Data Set:</legend>
    <table class="signup-label" cellpadding="5px">
    <tr>
    <td ><asp:RadioButton Checked="true" runat="server" ID="rdoSelectNew" GroupName="select" /></td>
    <td align="left" valign="baseline">Just my NEW leads please!</td>
    </tr>
    <tr>                                           
    <td><asp:RadioButton runat="server" ID="rdoSelectDefault" GroupName="select" /></td>
    <td align="left" valign="baseline">The most recent <telerik:RadNumericTextbox ID="txt1ClickNumberToPrint" runat="server" NumberFormat-DecimalDigits="0" Width="50px"></telerik:RadNumericTextbox> leads!</td>
    </tr>
    <tr>                                           
    <td><asp:RadioButton runat="server" ID="rdoSelectDateRange" GroupName="select" /></td>
    <td align="left" valign="baseline">The most recent <telerik:RadNumericTextbox ID="txtDateRangeNumberToPrint" runat="server" NumberFormat-DecimalDigits="0" Width="50px"></telerik:RadNumericTextbox> leads between the start date of <telerik:RadDateInput ID="rdiStartDate" runat="server"></telerik:RadDateInput>  and the end date of <telerik:RadDateInput ID="rdiEndDate" runat="server"></telerik:RadDateInput>!</td>
    </tr>
    <tr>                                           
    <td><asp:RadioButton runat="server" ID="rdoPreviousDataSet" GroupName="select" /></td>
    <td align="left" >
    <table cellpadding="2">
    <tr>
    <td>An Existing Mailing List:</td>
    <td><asp:DropDownList ID="ddlMailingList" runat="server"  SkinID="ExtraWideDll" DataTextField="Name" DataValueField="ID"></asp:DropDownList></td>
    <td><asp:ImageButton class="norm" ID="btnRefresh" runat="server" AlternateText="Refresh" ToolTip="Refresh the list of Mailing Lists" ImageUrl="./images/Refresh.gif" onclick="btnRefresh_Click" /></td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td align="right" colspan="2" ><asp:Button ID="btnGetData"  runat="server" Text="Print" onclick="btnGetData_Click" ToolTip="Print using the selected template!" />
    <asp:Button ID="btnPrintMailingLabels"  runat="server" ToolTip="Print Mailing Labels for an existing mailing list!"
                                                            Text="Get Mailing Labels" onclick="btnPrintMailingLabels_Click"  /><img title="Use the 'Print' Button to create a new mailing list, then use the 'Get Mailing Labels' button to get the mailing labels for the Mailing List." class="tooltip" src="./images/question.png" /></td>
    </tr>
    <tr>
    <td align="left" colspan="2" ><asp:Label CssClass="error" runat="server" ID="lblMessage"></asp:Label></td>
    </tr>
    </table>
    </fieldset>



  2. Jonathan
    Jonathan avatar
    134 posts
    Member since:
    Sep 2007

    Posted 30 Jul 2013 Link to this post

    Got it.  Need to use 
    $telerik.$(document).ready(function() 

    instead of 

    $(document).ready(function()

    thanks! :)
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top