How to call Controller action method from umbracoo - umbraco6

I am new to Umbracoo . I was trying to call Controller action method from umbracoo . I find the solution for how to render view but did not find any way to call action method of controller ..

for this purpose first you would have to inherit your controller from Umbraco.Web.Mvc.SurfaceController or Umbraco.Web.Mvc.RenderMvcController
have a look at:
http://our.umbraco.org/documentation/reference/mvc/surface-controllers
http://our.umbraco.org/documentation/reference/mvc/custom-controllers
Make sure that your view/partialView is created from umbraco backend as template so that it would have it's record save in database through unique id.
it would be hidden in your solution explorer first show all hidden items and the include in your project and start working on it.

Related

How to call action method using query string in mvc

Question: when new employee created I have to send mail to the admin. right now mail sending successfully but when admin clicks the link directly it should open the created employee partial view along with partial 1 and partial view 2 for your reference please find below the image.
i dont know how to do this one. right now directly i called the action method
Example:
it should call the following action method
//websitename/seachcountry
//websitename/listofemployee
//websitename/emplyesearchbyid
which is the best way to call from the email link.
Thanks.
To answer your question, to call an action using query string, your action should look like the following in your controller:
public ActionResult EmployeeInfo(string query)
{
// use query here
}
However, I suggest create an employee details action and view that would correspond to route like //websitename/employee/details/id.
This view must be tied to a viewmodel that contains all required info about the employee (including the data in partial views).

Creating a base controller default action for all ActionResults

I'm trying to find out if its possible to create a controller or action result in MVC that will trigger for every action.
Basically I want a check to occur before people are directed to the url each time, if this check fails I will return a different view but I don't want to write this out for every single action in my controller.
Can this be done??
This can be done with a custom ActionFilterAttribute.
Overriding OnActionExecuting means I can put the same check in for all actions.

MVC having same controller and action name in area folder too

I am having a action method in root folder New/NewForm. The partial view NewForm will be called from New controller... I have a New folder in Area folder too but the action method NewForm is not there in the controller NewController.. but while working from root folder i am invoking a ajax call for New/Newform but it is not getting called rather the application just hangs.. when i exclude the area folder "New" it is working fine. Any solutions would be great to me now as i need to solve this quickly..
Thanking you in advance.
Thanks,
Vin
If I'm not wrong
The ajax call which you are trying to make from your view will depend on the location of the view.
Suppose if your view is the Root Views then the url for the ajax call will be
url:'controller/actionmethod' I e url:'New/NewMethod',
If you want to make ajax call to a controller which is in an Area
For example Area name is Product
then the url will be url:'Product/New/NewMethod' Ie area/controller/actionmethod'
Thanks

Can't understand what this text is saying

I am following a tutorial and got to this point: http://rubysource.com/building-your-first-rails-application-views-and-controllers/
rails generate controller urls new
The reason we only passed in the new action (instead of new, create,
and show) is because Rails automatically generates a dummy view for
each action included in the generator call. In this case, we only want
a dummy view for the new action, so we exclude the others.
So why we only need to create the controller for new? Can someone plase explain it in a little more details?
The command is used to create the UrlsController with only one method: new.
This command will also automatically create a view file for you in:
app/views/urls/new.html.erb
Had you supplied more arguments like:
rails generate controller urls new create show
You would have gotten:
app/views/urls/new.html.erb
app/views/urls/create.html.erb
app/views/urls/show.html.erb
Since the tutorial only needs the new view it was unnecessary to create the additional views, hence those additional arguments were not added to the generate command.
Later in the tutorial you manually add the create and show methods, but you never add views for those methods (since those methods will not be needing specific views files in this application).
So: what you did was create the controller UrlsController with one method new, and the corresponding view for that method. The rest of the methods you will code in manually later in the tutorial so there was no need to auto-generate anything else (create or show).
This will only create the new action in the controller and should skip the other ones.
EDIT:
It will generate a controller called UrlsController in app/controllers and in that controller there will only be one method called action which corresponds to a route or url called urls/new

Call action from another Controller

I have a controller action.How can i call action method from another controller in asp.net mvc?
Is this a valid thing to do. Is it possible?
If you're first action is complete then you might redirect to another action.
If there is some common code between these two controllers that you don't want to duplicate then you'd probably look at creating a service which would have this and be called by both actions

Resources