0

Can someone help me with the following problem?

<asp:LinkButton ID="deleteButton" runat="server" CommandName="Delete" Text="Delete"
    OnClientClick='<%# string.Format("javascript:return confirm({0})",  Eval("Id")   ) %>'   />

I have a messagebox with only the 'Id' when i click on delete button. But i want to put some text before the 'Id' like are you sure to delete 'Id'? Im not so good in javascript so i hope someone can help me
thanks!

1

1 Answer 1

1

Create a JS function that looks like:

function confirmDeletion(id) {
  return confirm("Your message here: " + id);
}

Then call it from your ASP linkbutton tag onClientClick event handler.

Sign up to request clarification or add additional context in comments.

2 Comments

Try putting The eval tag inside the parentheses.
OnClientClick='<%# string.Format("javascript:confirmDeletion({0});", Eval("Id") ) %>' is the solution. thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.