Attributes.Add question

  • Thread starter Thread starter REB
  • Start date Start date
R

REB

If I add this line of code to a drop down list's SelectedIndexChanged event
is there something else I should add to keep things clean?
private void ddlDriver_SelectedIndexChanged(object sender, System.EventArgs
e)

{

btnDelete.Attributes.Add("onclick","return confirm('Are you Sure you want to
delete " + ddlDriver.SelectedItem.ToString() + "?');");

}

If a user deletes 100 drivers will the button have 100 added attributes or
is it just changing a property and modifying it each time?

Should I call
btnDelete.Attributes.Clear();

or is that uneccessary?
 
It'll just modify if it's already there otherwise it'll create it.

Suggestion: Why not add that attribute to the delete button when you load the page.. Do you have to use the postback event(costly) to add the onclick attribute?

----- REB wrote: -----

If I add this line of code to a drop down list's SelectedIndexChanged event
is there something else I should add to keep things clean?
private void ddlDriver_SelectedIndexChanged(object sender, System.EventArgs
e)

{

btnDelete.Attributes.Add("onclick","return confirm('Are you Sure you want to
delete " + ddlDriver.SelectedItem.ToString() + "?');");

}

If a user deletes 100 drivers will the button have 100 added attributes or
is it just changing a property and modifying it each time?

Should I call
btnDelete.Attributes.Clear();

or is that uneccessary?
 
Thanks for the reply.

I want the pop up to have the name of the record that is being deleted so
the user can see exactly what they are deleting before they commit to it.
 
Back
Top