The answer comes down to how lambda expressions such as
x => x.Name
work. In the end, the expression does not care if your model is null or not as it figures out how to render the textbox by looking at the defined property of the strongly-typed class you have defined.
So if you had class:
public class MyModel
{
public string Name {get; set;}
public int Age {get; set;}
.
.
.
}
and then in your veiw you reference your model like
@model MyModel
If you look at the source of TextBoxFor
TextBoxFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression)
Generic types are used. So, since you have a strongly typed view with
@model MyModel
Type TModel is MyModel and used with the HtmlHelper. Also
Expression<Func<TModel, TProperty>> expression
is composed with a
Func<In TModel, Out TProperty>
and thus the expression can be evaluated with both the model type and property type known. It does not matter whether you have an actual instance of the model or not.