Passing data structures through @value attribute of <option>
Hello;
Am I allowed to pass a data structure through the value attribute of option? Normally I see the passing of @model.somevalue where somevalue is just any variable of a basic type. But what if I want to pass in @model instead and access the class through a normal callback function? How do I explicitly type cast the ChangeEventArgs e.value to represent the type I'm interested in accessing? Such as Model value = (Model).Value; Is this allowed or even possible?
1 Reply
I'm thinking of the following:
<select @onchange="SomeCallBack><option @value=Model>Model.description</option></select>
And private void SomeCallBack(ChangeEventArgs e) {
Model value = (Model)e.Value;
}
C# does throw an error when encountering this snippet. It claims this is an invalid cast.