H Bıyıkcı
H Bıyıkcı

Reputation: 25

How Set Multi Texboxfor Values To 1 Textbox (MVC)

I have 2 TextBoxFor:

@Html.TextBoxFor(model => model.Name)  //Name
@Html.TextBoxFor(model => model.Surname)  //Surname

I want to combine these two textboxfor values in 1 textbox:

@Html.TextBox(... or    //Name surname
input type="text" ...

Thanks.

Upvotes: 0

Views: 1203

Answers (1)

Arvind Vishwakarma
Arvind Vishwakarma

Reputation: 563

Create property in your model named as FullName

public string FullName
{
    get
    {
        return String.Format(Name + " " + Surname);
    }
} 

And then use FullName in TextBoxFor helper,

@Html.TextBoxFor(model => model.FullName) 

Upvotes: 0

Related Questions