Link to home
Start Free TrialLog in
Avatar of Robert Treadwell
Robert TreadwellFlag for United States of America

asked on

Jquery: Refreshing DropDownLists in UpdatePanel

I have been trying for days to call my vb code from jquery function.  I am getting the Panel to update but call is not being made see code below and please advise.
Jquery:
 function addDDLOpenDialog(orgID, tableName) {
        var divName = "#OtherMedicationDialog";
        var ajaxUrl = "CRE.aspx/AddOtherMedication";
        $(divName).dialog("destroy");
        $(divName).dialog("open");

        $(divName).dialog({
            autoOpen: "false",
            title: "Add List Value",
            width: 500,
            height: 235,
            modal: true,

            //Define Buttons
            buttons: {
                Submit: function () {
                    var newValue = "";
                    newValue = $("#<%= omDialogTB.ClientID  %>").val();
                    //Submit form by calling webservice
                    $.ajax({ type: 'POST',
                        url: ajaxUrl,
                        data: '{orgID:"' + orgID + '", tableName:"' + tableName + '", newValue:"' + newValue + '"}',
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (msg) {
                            if (msg.d) {
                                //"ClientScript.GetPostBackEventReference(btnRefreshDDL, '')";
                                __doPostBack('<%= btnRefreshDDL.ClientID%>', '');
                            }
                        },
                        error: function () {
                            alert("Error! Try again...");
                        }
                    });
                    //Now close dialog
                    clearForm(divName);
                    $(this).dialog('close');
                },
                Close: function (ev, ui) {
                    clearForm(divName);
                    $(this).dialog('close');
                }
            }
        });          //end of Dialog w/options
    };  //End of openDialog Function 

aspx:
 <asp:UpdatePanel ID="MedicationInfoUP" runat="server" UpdateMode="Conditional" >
                              <ContentTemplate>
                              <asp:LinkButton runat="server" ID="btnRefreshDDL" OnClick="MedicalInfoUpdatePanel" style="display: none;" />
                                <div class="MIContent">                          
                                <!-- Beginning of Fieldset -->

Code behind:
 Protected Sub MedicalInfoUpdatePanel(ByVal sender As Object, ByVal e As System.EventArgs)
        'Retrieve Data from LINQ Datasource
        Dim db As ClientInfoDataContext = New ClientInfoDataContext
        'check to see if userID already exist.  If So then Basic Record exist already only updates are necessary
        'return userID by providing BadgeID
        Dim userID As String = ""
        If Not (String.IsNullOrEmpty(Request.QueryString("ID"))) Then
            userID = Request.QueryString("ID").ToString()
        End If
        AllergiesDS.Update()
        DietaryDS.Update()
        SpecialNeedsDS.Update()
        ImpairmentDS.Update()
        DiagnosisDS.Update()
    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of jagssidurala
jagssidurala
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial