Home > Blockchain >  Breaking string in to two lines in controller and send to view ASP.NET MVC
Breaking string in to two lines in controller and send to view ASP.NET MVC

Time:11-18

I want to know, There is a string that I want to break the value into two lines and set into the model, and pass it to the view.

In the view, it should be shown as 2 lines in the Text Area.

Is this possible to do?

This is the value that I want to break. I tried this

taskMain.Note = CustAddress.ToUpper()  " "  custHouseNo.ToUpper()   " "   City.ToUpper()   " "   provinceCode.ToUpper()   ", "   Country.ToUpper()   "<br/><br/>Customer Contact No : "   CustPhoneNumnber;

I want to break it into two lines from Customer Contact Number. The above is printed in one line with string

This is the view.

<div > 
   @Html.TextAreaFor(model => model.Note, 10, 400, htmlAttributes: new { @class = "form-control", @id = "TaskNote", placeholder = "Type Additional Notes here" }) 
   @Html.ValidationMessageFor(model => model.Note, "", new { @class = "text-danger" }) 
</div>

CodePudding user response:

Instead of using <br/><br/> to break up the string you can use \n\n like this:

taskMain.Note = CustAddress.ToUpper()  " "  custHouseNo.ToUpper()   " "   City.ToUpper()   " "   provinceCode.ToUpper()   ", "   Country.ToUpper()   "\n\nCustomer Contact No : "   CustPhoneNumnber;
  • Related