asp mvc file upload - asp.net-mvc

I have a form in asp.net mvc 3 project with some properties (a name and some extra properties who need to be filled in).
What i also need is a file to upload in the same form.
I placed an input type "file" and that works when i use Request.File the file is ok.
But i'm also using form validation, so when my name is not filled in, it's not possible to save. That works fine, but then my file is cleared..
Someone who has a good example to use file upload in a form? (with other fields and validation)

In addition to #Neil Knight's excellent references in his answer, if you're using ajax (and you probably are or will be to leverage MVC's ability to facilitate partial page refreshes) the jquery plugin here has proved itself useful in enabling file upload without a full page navigation.

Related

use of partial views (file upload forms on different pages)

I am very new to asp.net MVC.
I need to create dnd file "component". It allows user to upload file to server using DnD, the upload is done via webAPI. I am using FileModel here, for example, webApi also returns FileModel (to show uploaded file info on page). I did this part.
However, I did it in the "TestView". I need ability to add this "component" to any view on my project. Unfourtunately I do not have knowledge enough to do this.
I have found out that there are PartialViews. Should I just move my "TestView" to some "FileUploadPartialView"? What problems this will cause? How this affect the usage of FileModel?
Partial Views are like a javascript include. You shouldn't have any trouble.
Just put this wherever you need to have your partial view...
#Html.Partial("_FileUploadPartialView")
Let me know if you need more detail.

creating Entry form in Umbraco for Add/Edit/Delete/Search functions

This is repeatedly asked many times, however i couldn't find appropriate solution for my problem.
I want to create an Entry Form which will consists of following elements:
Text boxes, drop down fields (auto populated) , check boxes , radio buttons
After my research
i found that i need to create user control, or script file for above form and access it via Macro.
I don't want to use User control as my first preference is to controller-View-Model (i.e. cshtml)
I want to follow MVC approach to create above form. So
1) Do i need to create a seperate project for Add/Edit/Delete/Search Data Entry form?
2) OR i need to create cshtml file for the same(not so clear about this approach)
I'm looking this data entry form with easier for customization and i could use it in other applications as well.
From Umbraco 4.10 up to 6.0.x you can use MVC in Umbraco so there's no need to use an usercontrol. You probably want to use a SurfaceController where you can add any Action you want. The rest is standard MVC (Razor views to build your textboxes, drop downs, ...).
Check out the Umbraco MVC documentation where they explain how to use MVC in an Umbraco project.

File upload control for asp.net mvc

I'm writing an asp.net mvc application. I'm looking for free control to make file(s) upload. (Multiple files upload is not required). I found uploadify, ajax uploader, c5 filemanager.
I'm looking rather example which I could include in Razor form and add additional fields such as i.e. file description.
Do you have any specific control which you could suggest?
Uploadify in my opinion is the best.
Check out:
How do I get jQuery's Uploadify plugin to work with ASP.NET MVC?
its the same in mvc3.

How to create reusable component in Struts 2

Hi
I want to make reusable component in/for Struts 2 framework. For example, a login form having validations, authentication on form submission, error display, Forgot password link etc.
I want to create this form in such a way so that it can be placed anywhere within the site and in any site without any changes.
Please suggest what should I use or better if you can provide and reference for the example of such type of components.
Thanks
Krishan Babbar
Why not, this is Model View Controller, source code can be reused, for example if you want to go to another framework, everything you will need to modify is View, because each framework has its specific tags, you could do everything with simple html tags, but this is already a framework problem

Adding html form and input tags into Symfony static pages

I inherited the management of a Symfony site and need to add some HTMl form tags to one of the "static" pages via the CMS. The scenario I have is:
/index.php/splash/welcome pulls up the welcome screen.
We want to be able to add a subscription button on that page.
The HTML has been supplied for us by the company that handles the subscriptions.
The form post method has an action that references a script on a remote site (no lectures on the security implications please ;-).
When I add the <form... and <input... tags via the CMS admin panel, the tags get removed automatically by Symfony.
Is there a way to tell Symfony to allow these tags?
Thanks in advance,
Marty.
This is goign to depend completely on how the developer set up the CMS. Youre using a rich text editor in source mode i would take a look at that editor's config file and documentation because its probably the one responsible for stripping the tags.
If its just a plain text area i would check the submit action for the edit form and take a look at the code... he may be using something to strip them in there.
If youre using one of the Symfony CMS plugins (Diem, Apostrophe, Sympal) i might be able to help further if i know which one youre using. If its something custom we would need to see the code. This isnt really indiciative of the Symfony core, but rather the CMS youre using.

Resources