Javascript confirm box with c#
-
Hi guyss.. Actually in my web page a person-X can assign a task to another person-Y and on the dash board of Y that task will be displayed on opening the task it will show him the details of the task. the task can be completed by a series if activity. Now i have a button called add activity on clicking the button it redirects to the activity page. Now here i need some help actually the activity page has a status dropdownlist which has two options which is open and closed.. a person can create an activity with status open and later when the activity is over he can edit the activity and change the status to close.. Now when a person changes the activity status to close i need a confirmation box to popup asking the user whether the TASK IS COMPLETED (Not the activity) if the user clicks ok then the task is closed otherwise wen he clicks cancel button it should just update the activity status. Now i have made the confirmation box to popup but the problem is i am using javascript for the confirmation box when user clicks ok it closes the task but wen i click cancel i cant make it to just update the activity status.. Im confused wher do i write the code when the user clicks cancel button.. please guide me.. My code is as follows: When the status is changed to close:
private void ddlStatus_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(ddlStatus.SelectedValue.ToString() == "Closed")
{
btnAdd.Attributes.Add("onClick","javascript:return(confirm('Are you sure you want to close the Activity?'));");
}
}When user clicks ok the button click event gets fired:
private void btnAdd_Click(object sender, System.EventArgs e)
{
if(ds.Tables.Count > 0)
{
if(ds.Tables[0].Rows.Count > 0)
{
int id = Convert.ToInt32(ds.Tables[0].Rows[0].ItemArray[0]);
UpdateTextField(id,1,txtDesc.Text.Trim().Replace("'","''"));
UpdateTextField(id,2,txtIssues.Text.Trim().Replace("'","''"));
UpdateTextField(id,3,txtBusTechAdv.Text.Trim().Replace("'","''"));
}
}
}but where do i place my code when the user clicks cancel button bcoz on clicking cancel idont think any event gets fired.. Please advise me.. Thanx in advance, Tash.