i want to use the pop box to appear when the user click the delete button asking the user 'Are you sure you want to delete'.
But the problem is when the user first hits the delete button the pop up message doesnt show up but when the delete button is clicked second time then the pop up message shows.
Can someone help me in this please. here is my code for reference:
protected void btnDelete_Click(object sender, EventArgs e)
{
btnDelete.Attributes.Add("onclick", "javascript:return confirm('Are you sure you want to delete')");
lblMessage.Text = "Testing";
lblMessage.Visible = true;
}
Loading
Niradhip ChakrabortyPosted Apr 16, 2008, 1:58 PM
Use the onclick attribute in page load.
I mean to say inspite of using
(btnDelete.Attributes.Add();)
this inside delete button event u can use it in page load.
Your code will look like below:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
btnDelete.Attributes.Add("onclick", "javascript:return confirm('Are you sure you want to delete')");
}
}