Why this code doesn't work?
OnClientClick='<%# String.Format("return confirm('¿Está seguro que desea eliminar el registro {0}?);'", Eval("data")) %>'
The error is:
The server tag is not well formed.
How can I write this to make it work?
Why this code doesn't work?
OnClientClick='<%# String.Format("return confirm('¿Está seguro que desea eliminar el registro {0}?);'", Eval("data")) %>'
The error is:
The server tag is not well formed.
How can I write this to make it work?
The second ' is telling the string to end. Escape it using a backslash. Same with the ending apostrophe.
OnClientClick='<%# String.Format("return confirm(\'¿Está seguro que desea eliminar el registro {0}?);\'", Eval("data")) %>'
Try that.
Use @ at the start of the string so that escape characters are not processed. See http://msdn.microsoft.com/en-us/library/362314fe(VS.71).aspx
OnClientClick='<%# Eval("data", @"return confirm('¿Está seguro que desea eliminar el registro {0}?);'") %>'
It also appears that the string within the confirm function is not closed prior to the closing paren. Should be:
confirm('¿Está seguro que desea eliminar el registro {0}?');