简体   繁体   中英

Ajax.BeginForm in codebehind

Is it possible to use Ajax.BeginForm in the Controller ? Cause I want to create a form in the Controller and then write it in the HTML after an AJAX request. Or is there a better way?


Now I use a PartialView but it doesn't work... How can I render it with Ajax?

I'm understanding your question as you want to return an HTML fragment as a response to a client's AJAX request, but do not know how.


Of course there is a better way. It's MVC and you really shouldn't have View code in your Controller unless you truly can't help it. :)

Just create a partial view and render it as a response by return PartialView() .

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