简体   繁体   中英

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 jquery 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM