开发者

Jquery, ASP.NET MVP and data synch... dilemma

开发者 https://www.devze.com 2023-03-07 19:44 出处:网络
Ok. this is my situation. I am working on a website. It\'s on ASP.NET and i am using MVP pattern. I am very curious about Jquery (and Jquery Ajax) and i need to do a lot of ajax/asynchronous calls th

Ok. this is my situation.

I am working on a website. It's on ASP.NET and i am using MVP pattern. I am very curious about Jquery (and Jquery Ajax) and i need to do a lot of ajax/asynchronous calls throughtout my website.

But, i faced my first challenge... and i am clueless. I have a webform with two usercontrols. One is a datagrid with all the Clock In/Out of the employee for the week. The other user controls is nothing but a label showing the current status of the employee (Clocked In or Out) and a button to perform the corresponding action (clock the employee in or out)

so, technically, when the page loads, it loads the grid with 10 records in one UC (usercontrol)... then when we click on the button in the other UC, i want to add that new record to the grid using jquery ajax.

i don't see how. And the way i see it possible... i better do a full refresh because it's like u开发者_运维技巧sing a cannon to kill a fly.

let's say i click on the button... $mybutton.click(){ ajax call to add new record } ... that's no problem. Now, how the datagrid "knows" about this new record? do i have to create a new ajax call for the grid to load the new data once i get a onsuccess from my previous ajax call?

thanks


If I were you, I would scratch the DataGrid altogether, and make my web page get the entire data grid via AJAX.

You'll have to populate the grid yourself and add it to the page DOM. It's easy to do with jQuery.

Then you make your AJAX call to add a new record, and add this record to the grid using the same function you used when you were populating the grid initially.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号