I have a text area.
<textarea style="font-size:15px;text-align:left;width:500px;height:150px" class="control-label" id="txtTextoTemplate">{{txtTextoTemplate}}</textarea>
This text, I need it to modify a text that I use in conjunction with a library to send mails automatically. Suppose that in the text area I write the following
hola
este es un
ejemplo
del error
Using the following function in JS, I get the text:
var TextoTemplate = document.getElementById('txtTextoTemplate').value;
and in the following method I call my function of c #, sending the necessary parameters.
$scope.Guardar = function () {
$scope.isViewLoadingGuardar = true;
$("#btnGuardar").prop('disabled', 'disabled');
$scope.MostrarMensajeOk = false;
$scope.MostrarMensajeError = false;
//Obtengo el texto del textArea
var TextoTemplate = document.getElementById('txtTextoTemplate').value;
$http({
method: 'POST',
url: baseURL + 'Configuracion/ModificarTemplate/?Id=' + $scope.Id + "&Texto=" + encodeURIComponent(TextoTemplate) + "&Nombre=" + $scope.lblNombreTemplate,
}).success(function (result) {
if (result != null) {
$scope.isViewLoadingGuardar = false;
$("#btnGuardar").prop('disabled', '');
$scope.MostrarMensajeOk = false;
$scope.MostrarMensajeError = false;
$scope.volver();
}
}).error(function (data, status, headers, config) {
$scope.isViewLoadingGuardar = false;
$("#btnGuardar").prop('disabled', '');
alert(data);
$scope.MostrarMensajeOk = false;
$scope.MostrarGrilla = false;
$('html, body').animate({ scrollTop: 0 }, 'slow');
});
};
but what this function sends me is "Hello, this is an example of the error." So how can I get the line breaks to insert the "\ n" character in my sql? The character "\ n" are the line breaks. By C # I can not, since to the next method
public IHttpActionResult ModificarTemplate(int Id, string Texto, string Nombre)
{
try
{
//guardo el dato en la base.
}
catch (Exception ex)
{
//error al guardar
}
}
the Text variable and I get everything together.