This project is read-only.

How to used "ViewBag"?

Topics: Writing modules
Jul 29, 2011 at 5:04 PM
Edited Jul 29, 2011 at 5:32 PM

protected override DriverResult Editor(
AddressPart part,
dynamic shapeHelper) {

return ContentShape("Parts_Address_Edit",
() => shapeHelper.EditorTemplate(
TemplateName: TemplateName,
Model: BuildEditorViewModel(part),
Prefix: Prefix));

Is there another easy way to used mvc 3.0 "ViewBag" in Editor,?

 What is "Prefix" for?

And I try to " Model:new { Name = name, Part = part}" don't work :(

Jul 29, 2011 at 8:57 PM

The prefix is necessary to disambiguate form fields when multiple parts contribute to the same edit screen.

What do you mean about ViewBag?

Jul 30, 2011 at 7:00 AM

I want  to pass data from Controllers to Views same as  use ViewData[] dictionary in Editor,Is that possible?

If I want pass many parameter from Controllers to Views and didn't declared a class, what can I do?

Aug 3, 2011 at 12:41 AM

Well, you can, it's MVC. There is no prefix to use, you could just use ViewBag as you would in any MVC app. But well, you shouldn't: in Orchard we use more dynamic objects called shapes. You can stick any data on those shapes and recover them from a template using the same property name on Model.

Jul 2, 2012 at 5:28 AM

Could you please explain how to pass object from driver to view? Should I use shapeHelper? How to retrieve data?

Jul 2, 2012 at 7:58 AM

Stick it onto the shape. There are thousands of examples throughout the code. The shape becomes the model from the View, making it trivial to recover.