Click here to Skip to main content
15,883,606 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
Hello all experts,

This may be a stupid question but please help me because of me being bit naive in jQuery.

On my asp.net page, I have

All necessary references to jQuery library
Asp.net treeview
Two combo boxes
One asp.net button

The process is: When the user clicks on the button, the code behind utilises the selected value of the two combo boxes to call the database and then return a datatable of which the records will then be populated in the treeview.

In a normal scenario, doing a postback on button click, this works fine.

What I am doing is using jQuery AJAX call ($.ajax) to call the same page with the POST method and passing the combo boxes value as query strings.

Everything happens at the code behind and the database returns the required records. The code behind code does execute populating the treeview, but, in the front end, this is not shown at the end of the AJAX call.

Can anyone please shed some light?

Thanks.

Regards,
Nayan
Posted
Comments
kishore sharma 1-Aug-13 2:22am    
can you provide client side script with ajax part
Nayan Ambaliya 1-Aug-13 2:27am    
var selectedCB1 = $("#<%=cmbCB1.ClientID%> option:selected").val();
var selectedCB2 = $("#<%=cmbCB2.ClientID%>").val();

var request;
request = $.ajax({
url: '<%=ResolveUrl("~/AllProcesses/Process156900.aspx") %>?ProcessToPerform=Process156900&CB1=' + selectedCB1 + '&CB2=' + CB2,
type: 'POST',

});

request.done(function() {

$('#<%=pnlProcess156900.ClientID %>').dialog({
width: 850,
height: 700,
show: 'slide'
});
alert($("#<%= tvProcess156900.ClientID %>").children("div").siblings("table").length);
});
request.fail(function(jqXHR, textStatus, errorThrown) {
alert('Error occured: ' + textStatus + ' | Error thrown: ' + errorThrown);
});

return false;
kishore sharma 1-Aug-13 5:31am    
by looking at this script there is nothing you are doing with the returned data.
Nayan Ambaliya 1-Aug-13 7:52am    
Hi Kishore,

Thanks for your time.. I am getting the data in a datatable from DB in c# and then binding the treeview in C# itself. Therefore, I do not need data on the client side... Am I doing anything wrong..?? Sorry I am not an expert in this topic..

1 solution

If you do it manually in ajax you'll have to write all the client side code to update your treeview with the results that come back. A much easier approach is to use a control that already supports ajax or wrap it in an asynchronous update panel which can handle it for you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900