How to?
4 Apr 2018 / 1 minute to read
Render Button from Code behind
Button 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 Button properties in the controller.
//Namespace to get the JavaScript (Button) component properties
using Syncfusion.JavaScript.Models;
namespace MvcApplication.Controllers
{
public class ButtonController : Controller
{
// GET: Button
public ActionResult ButtonFeatures()
{
//Initializing the Button model
ButtonProperties BtnObj = new ButtonProperties();
//Initializing the datasource and other properties
BtnObj.Text = "Button";
BtnObj.ShowRoundedCorner = true;
//Passing Button properties using the ViewData
ViewData["BtnModel"] = BtnObj;
return View();
}
}
}
Binding the Button properties passed via ViewData from the controller in the client side as below.
@{
Html.EJ().Button("searchCustomer",(Syncfusion.JavaScript.Models.ButtonProperties)ViewData["BtnModel"]).Render();
}
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