c# - Best method to creating re-usable sections in asp.net-mvc -


I have a form that I want in different parts of my website.

Users enter their address, and submit the form that saves the address. I want to wrap it up, so in some places I can use it again after the same functionality is required.

I am thinking of doing this:

  1. Make a partial view with the form, but the Action Location URL has been passed as a parameter .

  2. Create a separate class / method that will handle server-side verification (

  3. saving / editing is already controlled in the DB layer Is there a better way to do this?

ASP.NET uses the communication on the MVC configuration so that you can use it to send your address to different tasks, where it was requested that it was requested since . If you keep things in heaven:

  public action Foo () {return view ();} [AcceptVerbs (HttpVerbs.Post)] Public Zero Foo (string address) {// Code to update address}  

Your address will be partial in your Foo.aspx view, using helpful methods to create your own form in your partial view:

  using ; & lt;%}%>  

Then When the form is posted, you can post it Is ripe to accept that which can be expected to call fu action HTTP Post.

Now, if you create a new view called the bar, ASPX includes partial view with two new functions to serve your page and then accept the post data:

  Public Action Bar () {return View (); } [AcceptVerbs (HttpVerbs.Post)] Public Zero Times (String Address) {// code to update address}  

To say this to you, in any part of your data, No need to pass it where to post it, because it is used to use naming conventions, i.e. when / mat controller / fu, html Is served from. BeginnForm will present / MAC Controller / Foo as the posting action / same with MyController / Bar

Hope this kind of clear!


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -