Calling WebMethod via jQuery from JavaScript on ASCX, needing value of Control
<p>I understand how to use jQuery to make an AJAX call to a WebMethod from a normal page, but I'm running into problems doing it from a UserControl (ASCX). Right now the biggest Issue I'm having is that the JavaScript for getting access to the groupDropDown control is not working.  It seems that since this is a UserControl hosted within DotNetNuke, the ususal method of getting the CLientID is not working since it is nested down x number of levels. Here is what I have:</p>

<p>Javascript:</p>

<pre><code>function validateEnrolledDate(src, args) {
    var isValid;
    var groupDropDown = document.getElementById('&lt;%= ddlDealer.ClientID %&gt;');

    $.ajax({
        type: "POST",
        url: "ajaxservice.asmx/ValidateEnrolledDate",
        data: "{orderDate: '" + args.Value + "', groupId: '" + groupId + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function (msg) {
            alert(msg);
            isValid = msg.d;
        },
        failure: function () {
            alert("FAIL");
        }
    });
    args.IsValid = isValid;
</code></pre>

<p>Validator User Control that calls this JavaScript:</p>

<pre><code>&lt;asp:CustomValidator id="CustomValidator1" runat="server" ControlToValidate="rdiDate" ErrorMessage="Fail" OnServerValidate="CustomValidator1_ServerValidate" ValidationGroup="vgce" CssClass="validation" Display="Dynamic" Text="*" ClientValidationFunction="validateEnrolledDate" /&gt;
</code></pre>

<p>groupDropDown I'm trying to get a value from:</p>

<pre><code>&lt;asp:DropDownList ID="ddlDealer" runat="server" CssClass="dropdownlist theDealer" TabIndex="3" AutoPostBack="true" OnSelectedIndexChanged="ddlDealers_Changed" /&gt;
</code></pre>

<p>WebMethod:</p>

<pre><code>[WebMethod()]
    private bool ValidateEnrolledDate(string orderDate, string groupId)
    {
        DateTime enrolledDate = new Service().GetEnrollmentDate(int.Parse(groupId));

        if (DateTime.Parse(orderDate) &gt;= enrolledDate)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
</code></pre>

<p><strong>TIME TO SIMPLIFY:</strong>
Here is testing JS Code:</p>

<pre><code>function validateEnrolledDate(src, args) {
    var isValid;
    var selectedGroup = $("theDealer").val();

    alert(selectedGroup);
}
</code></pre>

<p>I'm now just referencing a TextBox:</p>

<pre><code>&lt;asp:TextBox ID="dealerId" runat="server" CssClass="theDealer" /&gt;
</code></pre>

<p>The Text in the Textbox is being set in Server Side code, and it is visible on screen.</p>

<p>The alert message is "undefined", so something is still happening so that it is not getting the value of that textbox...</p>
