It just says:Error 1 'System.Web.WebPages.Html.HtmlHelper'
does not contain a definition for 'BeginUmbracoForm' and the best
extension method overload
Umbraco.Web.HtmlHelperRenderExtensions.BeginUmbracoForm(System.Web.Mvc.HtmlHelper,
string, System.Type)' has some invalid arguments
If i add:
@using Umbraco.Web.Mvc
it say the same error, but the VS error highligting also highlights Html
I can as a workaround make Partial View which is then loaded by a Partial View Macro, but is that really the correct/only way?
hi, yea i mean as long as you can make a post and called a controller and action then its possible, so javascript/jquery ajax would work. But thats not really solving your problem :)
Try removing and replacing Umbraco.Web from your bin directory. Also does everything else work with MVC/razor? Is it just this? Charlie :)
How have you got your project setup at the moment?
Sure. ummm replace the Umbraco.dll in your bin. That should the umbraco.web you need. You could call an action using ajax using
$.ajax({// edit to add steve's suggestion.//url: "/ControllerName/ActionName", url:'', success:function(data){// your data could be a View or Json or what ever you returned in your action method // parse your data here alert(data);}});
But in razor you would just use something like
@using (Ajax.BeginForm("action", "controller", option param, new AjaxOptions() { UpdateTargetId = "UpdateTargerAfterSuccessfullPostback" }, new { ID = "HtmlAttributeForTheForm" }))
If i use the Ajax.BeginForm i get: Error 19 The type or namespace name 'BeginForm' does not exist in the namespace 'System.Web.Mvc.Ajax' (are you missing an assembly reference?)
So this is kind of the same problem as with the Html.BeginForm
Yes i have the dll in my bin. Remember this is al working in a Partial View, just not in a Macor. @Ajax is not working, but is working in the Partial View
I would not use macros tbh, you will find it so much easier with out them. If you just create you views in the views folder and partials in your macropartials folder you should be fine. If you show me sohw code i can help you out :)
What you will do is start with a View say HTML. This will have HTML.renderbody().
This will be the template(view) that you have defined somewhere and is attached to a node in the umbraco tree.
In your view say 'HomePage' you would then call
@Html.Partial('your partial view', 'your model')
In the partial view 'your partial view'
you would then do your ajax/form post to the controller and action, which is inherting the suface
So all you need in Umbraco backend
In the templates you will have your view and in the Developer/Macros you will have your partial views where if you click on one you will see
'UseMVCPartial' where its pointing to the physical file.
This might be slighty diffrent in 6.0.3 i am looking at 4.11.1
Yes, but need a view that calls a partial, so in your template section in Umbraco
HTML
VIEW
VIEW
VIEW
VIEW
Then in the content tree
Home node
Template
VIEW
Doctype
DOCTYPE
In VIEW call a partial,
Also where you are using @inheritsUmbraco.Web.Mvc.UmbracoViewPage<Falk118.Models.ContactViewModel> I personally have found no benefit in this and use @model Falk118.Models.ContactViewModel
Make sense? :) Charlie.
Also why do you have the javascript at the end? Should this not be taken care of though your controller and in a class somewhere?
No problem, let me see your code when you have got it and if it does not work. Should be failry simple and should be able to call your controller and actions :)
Using Html.BeginUmbracoForm
I am using Umbraco 6.0.3 MVC, and would like to make some forms that uses some SurfaceControllers, however i have no idea what to inherit or using.
When using
@using umbraco.MacroEngines
@inherits umbraco.MacroEngines.DynamicNodeContext @using (Html.BeginUmbracoForm("LoginForm", "LoginSurfaceController")) { ...
It just says:Error 1 'System.Web.WebPages.Html.HtmlHelper' does not contain a definition for 'BeginUmbracoForm' and the best extension method overload Umbraco.Web.HtmlHelperRenderExtensions.BeginUmbracoForm(System.Web.Mvc.HtmlHelper, string, System.Type)' has some invalid arguments
If i add:
@using Umbraco.Web.Mvc it say the same error, but the VS error highligting also highlights Html
I can as a workaround make Partial View which is then loaded by a Partial View Macro, but is that really the correct/only way?
mvh
Michael
Hi Michael
Perhaps you can get some hints from this post http://our.umbraco.org/m?mode=topic&id=28394
Hope this helps.
/Jan
I would use just a normal form post or ajax post instead of using the umbracobeginform. I have found this more flexable.
All you need is a controller that inherits from SurfaceController.
so
namespace
{
YourControllerNameSurface: SurfaceController
{
public ActionResult YourName (someparam sp)
{
}
}
so in your form:
Action: YourName
Controller: YourControllerNameSurface
Hope this helps.
You can also do hijacking where before the page is rendered you can drop into an action based on a doc type or template:
Say i have a doc type of Html and a template of Form, you can do:
public class HtmlController : RenderMvcController
{
public ActionResult Form(someparam sp)
{
//logic goes here
}
}
Anytime a page with a doc type of html and template of form loads it will drop into that code. Hope this helps. Charlie :)
Micheal, the problem you are having is that you have
@inherits umbraco.MacroEngines.DynamicNodeContext @using (Html.BeginUmbracoForm("LoginForm", "LoginSurfaceController")) { ..
on the same line you need
@inherits umbraco.MacroEngines.DynamicNodeContext
@using (Html.BeginUmbracoForm("LoginForm", "LoginSurfaceController")) { ..
Hi Charles
Thank you for your input, In my code a have it on separate lines, this was just a copy paste error. However that doesn't help.
Is it possible to call a surface controller from any page via jQuery? (Assuming this is a macro the user can add anywhere)
mvh
Michael
hi, yea i mean as long as you can make a post and called a controller and action then its possible, so javascript/jquery ajax would work. But thats not really solving your problem :)
Try removing and replacing Umbraco.Web from your bin directory. Also does everything else work with MVC/razor? Is it just this? Charlie :)
How have you got your project setup at the moment?
Hi Charlie
True, but i would like to go the jQuery way also :-). Can you give an example of this? I Haven't been able to find anything.
Everything else is working in the project. My setup is made just like this description: http://www.ben-morris.com/using-umbraco-6-to-create-an-asp-net-mvc-4-web-applicatio
I do not have an Umbraco.Web, only Umbraco.Web.UI
Sure. ummm replace the Umbraco.dll in your bin. That should the umbraco.web you need. You could call an action using ajax using
Hmm not sure what you mean about the dll's. There is no umbraco.web in the 6.0.3 package
thanks for the examples, i will play around with them also :-)
And there is a Umbraco.web in version 6.0.3 :) Try relpacing the dlls. So in your bin remove the umbraco dlls and replace them. Charlie.
No change :-(
If i use the Ajax.BeginForm i get:
Error 19 The type or namespace name 'BeginForm' does not exist in the namespace 'System.Web.Mvc.Ajax' (are you missing an assembly reference?)
So this is kind of the same problem as with the Html.BeginForm
Are you in razor? A .cshtml file?
Yes i have the dll in my bin. Remember this is al working in a Partial View, just not in a Macor. @Ajax is not working, but is working in the Partial View
br
Michael
Ahhhhhhh i seeee :) Why are you trying to use it in a macro?
Well, as i started out with:
I can as a workaround make Partial View which is then loaded by a Partial View Macro, but is that really the correct/only way?
I am just thinking why do i have to make two files for this to work. Maybe I am not understanding the Mvc/Umbraco concepts here? :-)
If i put the same code in the Partial View Macro it is not working either
I would not use macros tbh, you will find it so much easier with out them. If you just create you views in the views folder and partials in your macropartials folder you should be fine. If you show me sohw code i can help you out :)
What you will do is start with a View say HTML. This will have HTML.renderbody().
This will be the template(view) that you have defined somewhere and is attached to a node in the umbraco tree.
In your view say 'HomePage' you would then call
@Html.Partial('your partial view', 'your model')
In the partial view 'your partial view'
you would then do your ajax/form post to the controller and action, which is inherting the suface
So all you need in Umbraco backend
In the templates you will have your view and in the Developer/Macros you will have your partial views where if you click on one you will see
'UseMVCPartial' where its pointing to the physical file.
This might be slighty diffrent in 6.0.3 i am looking at 4.11.1
Does this make sense?
Hi Charles
Yes i think that makes sense. Let me wrap up what i have:
I have the standard layoutstuff that calls renderbody().
Then i have a Macro that calls a MVC Partial View:
And then the Partial View:
So i think this is what you are saying, isn't it?
Yes, but need a view that calls a partial, so in your template section in Umbraco
HTML
Then in the content tree
Home node
Template
VIEW
Doctype
DOCTYPE
In VIEW call a partial,
Also where you are using @inheritsUmbraco.Web.Mvc.UmbracoViewPage<Falk118.Models.ContactViewModel> I personally have found no benefit in this and use @model Falk118.Models.ContactViewModel
Make sense? :) Charlie.
Also why do you have the javascript at the end? Should this not be taken care of though your controller and in a class somewhere?
I think so :-)
thanks for all your help
No problem, let me see your code when you have got it and if it does not work. Should be failry simple and should be able to call your controller and actions :)
is working on a reply...