Results 1 to 3 of 3

Thread: Adding form fields and receiving them in controller

Hybrid View

  1. #1

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Adding form fields and receiving them in controller

    It's a weird situation. I have a table in the database which stores details of files uploaded on the server. I have a controller and view in place for managing data in this table.

    I also have a controller/view to upload files to the server.

    I want to combine these two into a single view. But I don't know how.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  2. #2
    Hyperactive Member Krokonoster's Avatar
    Join Date
    Jan 2010
    Location
    Cape Town
    Posts
    448

    Re: Adding form fields and receiving them in controller

    Dude, you should have nothing related to the database in your controllers.
    Controllers should just pass on data to and from your view to and from your repository implementations.

    Saying that:
    Create a viewmodel which will contain the data you want to send to the database, as well as a collection of files you want to upload.
    When the model get posted to the controller, pass off the fields that must go to the database to a repository function doing that, and the files to another function doing that.

    Something in that line. But the way you asked make it sound like you want to look a bit more at MVC best practices.
    Don't over complicate things like they do in WebForms. Controllers should be thin. They just orchestrate things.


  3. #3

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Re: Adding form fields and receiving them in controller

    I understand the general principles, however there are often constraints in what we can and cannot do. I had to drum up the interface to a small database in a very short time, and MVC at least automated most of the mundane tasks for me, coupled with ADO.Net Entities. All I need is a way of extending just one form to accomodate the file upload.

    I am well aware my MVC may not be the best, but right now, it's the best that I can do.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width