Im new to umbraco, Im using a umbraco surface controller to enter data to database , Normally i use #Html.ActionLink to call to action methods like delete,edit,details etc. Above function cannot be used in umbraco so i want to know how to do that kind of thing in umbraco?
If you have an IPublished item you can just call item.Url inside the href of an anchor tag. this would do the trick.
Related
I am trying to use ViewComponents tag helpers in CKEditor to show some products but it doesn't.
I created a vc tag helper like this :
<vc:products html-class="col-12 col-md-5" html-style="" skip="0" take="10"></vc:products>
Now I am trying to use this code in CKEditor, I mean post editors can call products anywhere they want. but it doesn't work. CKEditor shows it as a html code.
what should I do?
This code will be actually executed on the server side and it will add partial html to your page then the server will return it to the client.
<vc:products html-class="col-12 col-md-5" html-style="" skip="0" take="10"></vc:products>
Here I'm not sure what you are trying to accomplish, but you cannot dynamically use tag helpers on the client side. May be this link can help you.
Dynamically Produce Razor Views at Runtime?
I'm new to web development and ASP.NET MVC 4
My question is: Is it possible to replace the content of div tag without needing to refresh the whole page?
If so, what is the best practice of it (best use of MVC 4)?
In order to refresh partial content of a page, you have to use AJAX. There are plenty of resources available online describing how to implement this in ASP.NET MVC. One of the possibilities is using partial views, on which you can find a good tutorial here. However, if you're comfortable with javascript/jQuery a partial view might be overkill if you're just looking to update one div.
Use javascript and make an ajax call. MVC has a JsonResult for the controller you can use if you like.
Not 100% sure but if I remember right, jQuery is bundled with MVC4. Correct me if I'm wrong.
// Javascript code
$('#mydiv').load('/Content/html/mySnippet.html');
Would replace the contents of a <div id="mydiv"></div> with the contents of the /Content/html/mySnippet.html.
You can also call an action and return a partial view if you wish to have dynamic content instead of a static html template.
I want to generate menu from database for that I have implemented my logic and its responding well, the issue is that I am unable to render menu from my controller method. I want to ask if its possible to return HTML from action controller method and render it on my view by using Html.Action("MenuGenerator","Menu") but I am unable to achieve this. Moreover I donot want to create partial view for menu since my method returns menu as html string and I just want to flush it out to the view.
Html.Action is a basic helper method. All it does is return a MVCHtmlString. You will have to create your own helper extension that returns your custom HTML to build your menu.
I'm newbie in CakePHP and I have a few questions.
I'm trying to set up my first CakePHP website, and I want to display menu with links in my layout. I've created model called MenuItem, then I've created controller "MenuItemsController" and then a function show. When I access /menuitems/show/ all my links are displayed. So here's the problem. I want do call this controller in my layout so links will be visible on every subpage. First question is how to call this controller, and second how will output look like ? Do I have to create view for this cotroller if I don't want to use /menuitems/show/ or it's okay to set controller to output just array of data ?
Thank you!
First question is how to call this controller, and second how will output look like ?
Use requestAction() to request the data from the view OR better, set it based on the page you're on in your AppController::beforeFfilter() method.
In your layout simply use an element $this->element('menu'); and use the set data in it or, if you go for requestAction() do this call inside the element, you can even cache the element.
Read the links to the CakePHP book in the text, the book contains example code as well.
I am using MVC 4 with some Kendo UI and I am new to both.
What I need is for my Kendo grid to redirect to another page when a row is clicked.
My initial thought was to create a function within the script section of the view that the grid is on and that function would call the other view that I need. However, I am not sure if this is possible because I believe the view is supposed to be separate from the controller.
I think that I need to somehow make all of this be able to work from within the controller but I am not sure how to get started.
Use #Ajax.ActionLink to call controller and receive partialView
If you are doing a post action you can use RedirectToAction() in your controller. If you need to change the window in JavaScript see below.
window.location.href = "#Url.Action("(Action)","(Controller)",new {id= (params)})";