Attributes.Add question

Discussion in 'ASP .Net' started by REB, Jan 29, 2004.

  1. REB

    REB Guest

    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?
     
    REB, Jan 29, 2004
    #1
    1. Advertisements

  2. REB

    Guest 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?
     
    Guest, Jan 29, 2004
    #2
    1. Advertisements

  3. REB

    REB Guest

    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.
     
    REB, Jan 29, 2004
    #3
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.