Articles in this section
Category / Section

How to send custom parameters to events in .NET MVC platforms?

2 mins read

This knowledge base explains the way to send custom parameter to events in ASP.NET MVC. You can just send the parameter as option to the widget on its creation and access it in the widget instance.

In general, any properties sent to the widget on its creation is accessible later via widget’s model property.

For other wrappers, also, we have come up with the same approach by setting up the parameter in the widget’s model and later retrieving from it.

JavaScript Solution

 

[JS]

<script>
    $(function () {
        $("#Spreadsheet").ejSpreadsheet({
            customParameter: { cellSave: { foo: "bar" }, cellClick: { baz: "qux" } }, //dummy params
            cellSave: "cellSave",
            cellClick: "cellClick"
        });
    });
    function cellSave(args) {
        var parameter = this.model.customParameter.cellSave;
    }
    function cellClick(args) {
        var parameter = this.model.customParameter.cellClick;
    }
</script>

 

MVC Solution

 

[CSHTML]

 

    @(Html.EJ().Spreadsheet<ItemDetail>("Spreadsheet").ClientSideEvents(events => events.LoadComplete("loadComplete").CellSave("cellSave").CellClick("cellClick"))
    )
 
<script type="text/javascript">
    function loadComplete(args) {
        this.option(customParameter, { cellSave: { foo: "bar" }, cellClick: { baz: "qux" } }); //dummy params
    }
    function cellSave(args) {
        var parameter = this.model.customParameter.cellSave;
    }
    function cellClick(args) {
        var parameter = this.model.customParameter.cellClick;
    }
</script>

 

ASP Solution

 

[ASPX]

<ej:Spreadsheet ID="FlatSpreadsheet" runat="server">
    <ClientSideEvents LoadComplete="loadComplete" CellSave="cellSave" CellClick="cellClick"/>
</ej:Spreadsheet>
 
<script type="text/javascript">
    function loadComplete(args) {
        this.option(customParameter, { cellSave: { foo: "bar" }, cellClick: { baz: "qux" } }); //dummy params
    }
    function cellSave(args) {
        var parameter = this.model.customParameter.cellSave;
    }
    function cellClick(args) {
        var parameter = this.model.customParameter.cellClick;
    }
</script>

Conclusion

I hope you enjoyed learning about how to send custom parameters to events in .NET MVC platforms.

You can refer to our ASP.NET MVC feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our ASP.NET MVC example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied