Click here to Skip to main content
15,922,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I'm currently investigating the possibility of creating a web based app instead of a stand-alone app.

we have alot of existing code in c# for accessing our databases and filtering search results etc that we want to reuse.

One of our databases we search is external and can take a while to get results, so we wanted to display a "getting results" prompt and then start populating a table as the results came in.

I've tried using an AsyncController but this doesn't seem to let me display the page (view) then update it with the callback function (unless I'm doing something wrong?)

I'm currently using Visual Studio 2013 Express at the moment, if anyone knows of any good tutorials for doing what I need with controllers etc I would be very grateful, I'm trying to avoid duplicating code in JavaScript

Thanks
Posted
Comments
njammy 21-Jan-14 9:02am    
Look at using AjaxControl tool kit, specifically the dynamic populate control.
Drop one of them on the page, link it to a div or other control.
Add javascript onclientclick event to the calling button/control. The javascript onclientclick event will construct e.g. pipe separated values e.g. user=john|maxrows=20|search=dbSearchString. Pass this parameter set into the dynamic populate controls 'populate()' method in js.

Put your Database search methods in a web method in a new web service. Set the dynamic populate control's servicePath property to this new web service name. e.g. fooBar.asmx and set the method name which will do the search.
Add a parameter to the search method / web method to accept a contexKey: your parameter set.
Split this by pipe character into key value pairs.

Use them in your DB search. once the data is back from the DB within your web method, construct html e.g. <table> and populate it with <td>'s etc for each data row returned.
Return the html markup from the web method. The dynamic populate control has a target control id, which you can assign to a div:id e.g. <div id='dbSearchResults'></div>.

The dynamic populate result will stuff the div with the markup from the web method.

there is no postback involved and you can show updates this way.

1 solution

Do NOT use the Microsoft AJAX control toolkit if you can help it. Just use AJAX via jquery and if you want your page to auto update, write a timer to make it make it's call regularly ( that's all that control will do, but if you write it yourself you can both control and understand it )
 
Share this answer
 
Comments
sHoE_FeRReT 21-Jan-14 16:21pm    
Thanks alot for the replies, looking for info on the AjaxControl toolkit with the dynamic populate led me to an example using the jQuery.getJSON that returned a JSON object from C# (like Christian suggested) For some reason I didn't look into the jQuery/Ajax side first as I presumed I would have to port existing code over to JavaScript etc...
Christian Graus 21-Jan-14 16:26pm    
Cool - the more you use jquery directly, the more control you have, and the more you know what you're doing.

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