Reputation: 1669
I am having a kendoUI TabStrip widget control. In it, I have two tabs : products and support.
The two tabs are two different views. I have defined the tabstrip like this :
<div id="tabs">
<div>
<iframe src="../Products/Index"></iframe>
</div>
<div>
<iframe src="../Support/Index"></iframe>
</div>
</div>
And in script :
$("#tabs").kendoTabstrip({});
Then tabs with their respective view pages are coming. But the products and support pages will not open directly. I mean in the url bar when I enter localhost:4567/Product/Index
, it will not open the page, it will only open when we select the tab.
I have defined for both controllers such actions :
[ChildActionOnly]
public ActionResult Index()
{
return View();
}
Then when I run the main page, it is getting an exception it will be called only by child action only. Where when I select the tab it should become child action. How can I rectify that problem? I have not included :
@Html.action("Index","Products")
If I need to include that, where should I add that? Hope you understand my question...
Upvotes: 0
Views: 924
Reputation: 768
The ChildActionOnly attribute ensures that an action method can be called only as a child method from within a view. An action method doesn’t need to have this attribute to be used as a child action, but we tend to use this attribute to prevent the action methods from being invoked as a result of a user request. Having defined an action method, we need to create what will be rendered when the action is invoked. Child actions are typically associated with partial views, although this is not compulsory
So instead
@Html.action("Index","Products").
you should try
@Html.Partial("Products").
Upvotes: 2