So I have a View
that contains 2 models
. Each model
has its own form and submit button.
Currently, I have both submit buttons are processed by the same controller
method and use reflection
to figure out which model type was passed. But it seems like there would be a better way... any ideas?
I have something like this:
Models:
public class Model1
{
// Elements
}
public class Model2
{
// Elements
}
Controller:
public ViewResult ConMeth(Object model)
{
Type t = model.GetType();
if(t == typeof(Model1)
{
// Do work for Model1
}
else if(t == typeof(Model2)
{
// Do work for Model2
}
else
{
// Do something else...
}
}