Is possible to set generic type by another class?
- by Soul_Master
I use ASP.NET MVC for serving web application and I want to create something like the following code.
<% using(HTML.Form(Model)) { %>
<% HTML.CreateTextBox('txt1', x => x.Property1);
<% }
From the above code, Form extension method will receive object that represent type of current Model object in current View page. Next, CreateTextBox method will receive type from Form method and I can bind textbox to some property of this model.
Update 1
The following code is code of CreateTextBox method that will create instance of TextBox class.
public static CreateTextBox(string value, Expression<Func<object>> bindedProperty)
{
// T should be receive from HTML.Form method or class
return new TextBox<T>(value);
}
Is it possible to creating some code that doing something like the above code?
Thanks,