Umbraco Option to define dropdown list via Umbraco - umbraco

I am facing an issue using Umbraco 7.0. My requirement is that I need to create a contact us form page and from that page an email will be sent to admin. I thought of creating .Net User Control for achieving
this functionality.
However, in Contact Us page, there is a field like "Functional Area" that client wants a drop down and in that he wants, Option to define drop down list via Umbraco.
Could anyone please guide me how to achieve the same.

Rather than using the old User Control method, you would be better off writing one using Razor which can use a Model populated with content. There is a nice example here of something very similar that you can extend
http://www.diplo.co.uk/blog/2012/5/24/creating-an-umbraco-form-using-pure-razor.aspx

Related

How to add an mvc page to umbraco

I have Umbraco 7.5 and I need to know how to create normal MVC pages for adding new data to my site.
Lets say I have a Doctype "Node" in back-office. I want to let some people be able to add/edit some nodes without going through back-office. How can I do it?
I've tried to create add my view and controller (the MVC way), but apparently Umbraco hijacks all routing and my controller won't hit at all.
I've googled the matter (which is hard since I am not looking for Umbraco forms :| )and I've found this. But I prefer not to add my form as a part of other page. I mean, does it make sense to create a page in back office from type "something" and then on its template I do my add/edit form of another type? Seems strange, right?
I appreciate any ideas/ solution to this matter
You have a couple of options here. You can create a physical page for the editor to sit on, and add the editor as a SurfaceController action (basically an MVC Partial with Postback, that is still part of the Umbraco pipeline). Your form can then use the Content Service API to update the details. The advantage of this method is your code will have access to all of the Umbraco methods and templating out of the box. You could also use WebAPI controllers for the form if you want to do it all client side with JS requests.
You could also use route hijacking: https://our.umbraco.org/documentation/reference/routing/custom-controllers this allows you to have your own custom controllers for Umbraco routes, rather than using the default Umbraco ones. This is a bit more work to set up.
Finally, you can also tell Umbraco to ignore certain paths entirely, and you could run your controllers on those paths. The disadvantage here is that as the routes are being ignored by Umbraco, you don't automatically have access to all the useful Umbraco templating etc.
I've used the first method recently, and it works fine. The only caveat is that allowing users to edit nodes will fill up the version table quite quickly if a lot of users are editing a lot of nodes (every time a node is saved, a version is created). If you're going down this route, you may want to investigate something like Unversion: https://our.umbraco.org/projects/website-utilities/unversion/ which helps to keep old versions more manageable in situations like this.

Orchard CMS and controller vs driver

I am a little ashamed for asking so many questions, but I really want to learn.
In Sipke's blog a webshop is created. There is one specific question that boggles my mind when trying to do something similar.
Let me spell out the basic requirements:
User registration form and login, etc. This one is covered by the blog and it works nice.
Creating product parts and so on. This one is covered and no problem there.
Ordering by filling in an order form and making the payment. See down
Having the order page maintainable by customer. See down.
Viewing your own orders and their status. See down
Maintaining customers and orders from backend system. This one is covered by the blog and I need to do some work there yet.
As for items regarding creating orders and viewing your orders. I have followed the approach for creating records and using standard MVC controllers. But then I encountered problems:
Menu for orders page. This I had to do manually after installing the module.
The order page itself. I had to create the view including title and so on. But I can imagine a customer wanting the order page on another menu and with a different title. And maybe add even some own content to the ordering page. This I couldn't achieve by using standard MVC approach. So maybe I am using the wrong approach here. So I was thinking about using contentparts for creating an order and displaying them and using the drivers and handlers for that. But before I go down that road and refactor everything I want to know if that is the right approach. A downside could be that once the module follows that route it can then not so easily be reused with customers that have other cms's capable of hosting an MVC3 module.
So when to use drivers, handlers and contentparts and when to use standard controllers and views.
You should use Drivers and Parts (with Handlers if needed) when you want to create functionality for content items. E.g. if you want to display a custom media with all products, you could create a Part (together with its Driver, etc.) to handle that. Read the docs on Parts.
If the functionality is not tied to content items the most possibly you want to use the standard MVC toolbox, it's fine. Look at the built-in modules how they do that. E.g. the Blog module uses controllers and views to show the admin UI, but has parts to enhance the functionality of for example the Blog content type.
To make things more complicated you can employ ad-hoc content items to build a page that you'd normally do with simple views, but that's an advanced topic :-).

Allow user to make email template with dynamic MVC variables

I'm very new to MVC 3. My client needs an admin page where she can edit basic email templates like "Dear %FirstName%, Your order has been placed" which I will create. When an order comes in, it will automatically then send an email to the person, using her template.
What I'd like to be able to do, is automatically match up the fields in the template (like %FirstName%) with the model fields of the order, i.e. Model.Order.FirstName when sending the mail. I could obviously use a helper class to manually go and regex things, but I'm looking for a Razor-esque method for this.
I've looked (briefly) at MvcMailer and RazorEngine for this, but can't quite work it out, as those tools seem to rely on a .cshtml file.
Does anyone know how to achieve what I'm trying to do? Any suggestions are appreciated!
You should consider looking at Fluent Email, which now supports razor syntax.
http://lukencode.com/2011/04/30/fluent-email-now-supporting-razor-syntax-for-templates/

How to save dynamicly created template in database?

I would like to enable users to create their own templates in my asp.net mvc web application.
For example, you would create a simple template like a log on control, 2 labels, 2 textboxes, and 1 submit button.
Is it possible to allow users to save such templates in a database and then use them/extend them later? Could you please give me an example or link that shows how someone already did something similar?
I have no idea how to get started.
This may give you some pointers http://mihkeltt.blogspot.com/2009/12/nvelocity-template-engine-sample.html

creating new usercontrols at runtime in ASP.NET MVC

My situation is that the user is creating an entity on my site which contains the particlars of the driectors of that company, name address etc..
The Director form is a separate user control with the appropriate textboxes etc.
At run time we don't know how many of these directors there will be so I need one to be able to use something like an "ADD DIRECTOR" or "DELETE DIRECTOR" button which will present or delete the another usercontrol to add the additional director.
Currently I am trying to make this happen within a pane of the JQuery Accordion control.
I have looked many places for how to do this but to no avail.
Can anyone tell me where I might find some inforamation about how I can do this?
All the best
Paul
This is not exactly "adding usercontrols". But I suggest you look at a template engine like this one: http://aefxx.com/jquery-plugins/jqote/

Resources