How to update my GridView or Repeater asp.net objects with AJAX?
I've written some pages with ASP.net Repeater
and GridView
objects. I've seen that some other programmers write pages with these objects; but they make these objects do very nifty things.
For example, I've seen pages 开发者_运维技巧where a user clicks on a button and a jQuery dialog appears. When the user enters data into the dialog and clicks a button, the data is submitted using AJAX and the gridview/repeater is updated without reloading the page or posting back.
What are good practices for accomplishing this?
The gridview and the repeater are ASP.NET objects that the .NET framework translates into HTML for you.
What those pages are doing is posting some data to the server. Waiting for new data then using standard DOM manipulation to change the auto generated HTML on the page.
Once the code gets to the client and it's handled asynchronously most of the data is done via DOM manipulation on the client without touching ASP.NET code.
Alternatively they use AJAX controls from ASP.NET like the update panel. I'm not certain how ASP.NET handler ajax calls internally as I'm restricted to the limited AJAX functionalities of .NET 2.0.
So what is are good practices:
Set up your asp.net controls to create nicely formatted HTML and manipulate it by hand using high-level dom manipulation libraries like jQuery., You need to have a good knowledge of your html output rather then your aspx files content.
I´m putting thouse controls into updatepanel[mode conditional]. i´m using jquery to edit some data, or maybe create data. Sending to server via webservice and after successfull saving, i reload the updatepanel. for me the easiest way
精彩评论