How to
28 Mar 2018 / 3 minutes to read
Render RadialMenu from Code behind
RadialMenu can be rendered from the code behind by initializing the required properties in controller and passing those properties via ViewData or Model to the client side.
The following code illustrates the initialization of RadialMenu properties in the controller.
//Namespace to get the JavaScript (RadialMenu) component properties
using Syncfusion.JavaScript.Models;
namespace MvcApplication.Controllers
{
public class RadialmenuController: Controller
{
public ActionResult RadialmenuFeatures()
{
//Initializing the RadialMenu model
RadialMenuProperties RadialmenuObj = new RadialMenuProperties();
//Initializing the items and other properties
List<RadialMenuBaseItem> obj = new List<RadialMenuBaseItem> ();
obj.Add(new RadialMenuBaseItem(){ Text = "Copy" , ImageURL = "http://mvc.syncfusion.com/demos/web/Images/RadialMenu/copy.png"});
obj.Add(new RadialMenuBaseItem() { Text = "Paste", ImageURL = "http://mvc.syncfusion.com/demos/web/Images/RadialMenu/paste.png" });
obj.Add(new RadialMenuBaseItem() { Text = "Undo", ImageURL = "http://mvc.syncfusion.com/demos/web/Images/RadialMenu/undo.png" });
obj.Add(new RadialMenuBaseItem() { Text = "Redo", ImageURL = "http://mvc.syncfusion.com/demos/web/Images/RadialMenu/redo.png" });
RadialmenuObj.Items = obj;
RadialmenuObj.ImageClass = "e-radial";
RadialmenuObj.TargetElementId = "radialtarget1";
//Passing Radialmenu properties using the ViewData
ViewData["RadialMenuModel"] = RadialmenuObj;
return View();
}
}
Binding the RadialMenu properties passed via ViewData from the controller in the client side as below.
<div id="radialtarget11" class="content-container-fluid">
</div>
@{
Html.EJ().RadialMenu("RadialMenu1", (Syncfusion.JavaScript.Models.RadialMenuProperties)ViewData["RadialMenuModel"]).Render();
}
<style type="text/css" class="cssStyles">
.e-radialmenu .e-radial {
background-image: url("http://mvc.syncfusion.com/demos/web/Images/RadialMenu/settings.png");
}
.e-radialmenu.e-displaynone {
display: block;
}
</style>
Was this page helpful?
Yes
No
Thank you for your feedback!
Thank you for your feedback and comments. We will rectify this as soon as possible!
An unknown error has occurred. Please try again.
Help us improve this page