开发者

Save data to SQL 2000 from asp.net page using jquery (C#)

I am currently looking for a good solution that implements this. I have a comments section and I want the comments posted to my database using j开发者_如何学Pythonquery and then the section gets refreshed without having to reload the page. How feasible is this and does it have any security or performance issues?

Thanx


In addition to Brandon answer, if you're using pure asp.net(not mvc), your jquery code could call asp.net pagemethod which than inserts data into a database.

Links:

http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/ How to accept a JSON string array in an .aspx Page method http://www.clientsideasp.net/2009/03/01/aspnet-ajax-poll-using-jquery-a-complete-implementation-with-admin-part/

cheers


My suggestion would be to use jQuery to perform an ajax POST to either a controller action (if you're using MVC) or an ASPX page (if you're using WebForms) in your site. From there, your action should coordinate the work of adding the comment record to the database and, if needed, returning a json result to your page.

If you're using MVC, you can secure the action by decorating the action in question with the [AcceptVerbs(HttpVerbs.Post)] attribute.

Beyond that, check out the Microsoft Web Protection Library for helpers for AntriXss, Sql Injection and the like.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜