In asp.net mvc view using textarea I want to bind the data

<div class="col-md-6">     <label>Describe Your Business, Achievement & Vision (Within 500 Words)</label>     <textarea name="Description" type="text" placeholder="DESCRIBE YOUR BUSINESS, ACHIEVEMENT & VISION WITHIN 500 WORDS" required="" value="@Model.Description"></textarea> </div> 

In asp.net mvc view using textarea I want to bind the data. after debugging I am getting the data in @Model.Description..But in front end it is not showing .Just where input type = text; those field are binding with data. But the field which are defined as textarea,there no data is coming ,it’s just showing only the placeholder. Can anyone help me to solve the issue??

Add Comment
1 Answer(s)

There are 2 solutions for this. You can write the code snippet as follows:

<div class="col-md-6">     <label>Describe Your Business, Achievement & Vision (Within 500 Words)</label>     <textarea name="Description" type="text" placeholder="DESCRIBE YOUR BUSINESS, ACHIEVEMENT & VISION WITHIN 500 WORDS" required="">@Model.Description</textarea>     </div> 

Note: The "@Model.Description" should be in between the <textarea>@Model.Description</textarea> tags. In your code snippet,@Model.Description provided as a "value" attribute. This is the reason why the code is not worked for you.

OR Another Solution: using @Html.TextAreaFor

<div class="col-md-6">     <label>Describe Your Business, Achievement & Vision (Within 500 Words)</label>     @Html.TextAreaFor(model => model.Description, new { style = "width: 200px; height: 150px;" , placeholder="DESCRIBE YOUR BUSINESS, ACHIEVEMENT & VISION WITHIN 500 WORDS", required="" } ) </div> 

Happy Coding!!

Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.