In my .aspx view I have a button to delete the object that the user is watching from the model. Before it confirm the action, I show a confirm message with jquery:
$('#btDelete').click(function(e) {
e.preventDefault();
$.confirm({
'title': 'Delete',
'message': "You will delete the object <i>" + <%: Model.Reference.ToString() %> + "</i>. Do you want to continue?",
'buttons': {
'Si': {
'class': 'blue',
'action': function() {
//some code to make the delete
}
},
'No': {
'class': 'gray',
'action': function() {}
}
}
});
});
The problem is the message section: 'message': "You will delete the object <i>" + <%: Model.Reference.ToString() %> + "</i>. Do you want to continue?".
When I show Model.Reference.ToString(). Reference is an string that represent the object (yes, I also try removing the ToString()). When the message displays the reference, in some cases works good and show the Reference (it's normaly a number):
But the problem is when that number begins by 0. If it's all 0 and then some number, it remove all 0 and only show the last number. For example, the string 0003 it shows as:
But more extrange is when the refence alternate 0 with other numbers. For example, the object with reference 03030 IT TRANSFORM AS 1560. Why?
As you can see in the image, in the title of the page (Details view) it displays correctly the reference (03030) and I use the same: </h1><%: Model.Reference %></h1>. But in the confirm message it made some extrange transformation and convert 03030 to 1560.... Any idea why this is happening?
Also, If there are some letter (like at666) the message don't even open. I tried with the message 'message': "You will delete the object. Do you want to continue?" And it works, so the problem is <%: Model.Reference.ToString() %>
This is the Model:
public class ObjectModelDetail
{
public int Id { get; set; }
public string Reference { get; set; }
public string Ramo { get; set; }
public string FechaCreacion { get; set; }
public string FechaFinalizacion { get; set; }
}