Attributes.Add question

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?
 
G

Guest

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?
 
R

REB

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top