adding Button question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kevin Blount

    adding Button question

    I need to create a page that lists a users Content, and allow them to
    add subscribers to or remove subscribers from that Content. The list may
    contain just one Content item, but it could just as easily contain 10
    Content items.

    Each Content item would look something like this:

    ---------------------------------------------
    <content title 1>
    <content description 1>
    add new subscriber:
    <textbox for subscribers e-mail address<button to add subscriber>

    list of current subscribers:
    <checkbox for subscribere-mail@addressof. subscriber
    <checkbox for subscribere-mail@addressof. subscriber
    <checkbox for subscribere-mail@addressof. subscriber
    <checkbox for subscribere-mail@addressof. subscriber
    <button to remove selected subscribers>

    --

    <content title 2>
    <content description 2>
    add new subscriber:
    <textbox for subscribers e-mail address<button to add subscriber>

    list of current subscribers:
    <checkbox for subscribere-mail@addressof. subscriber
    <checkbox for subscribere-mail@addressof. subscriber
    <checkbox for subscribere-mail@addressof. subscriber
    <checkbox for subscribere-mail@addressof. subscriber
    <button to remove selected subscribers>
    ---------------------------------------------

    I have two methods addSubscriber and delSubscriber that I need to call
    from one of the two buttons, and here's where I'm having trouble.

    using somthing like this:

    Code:
    <asp:Button ID="testBtn" runat="server" oncommand="addSubscriber"
    Text="Add Subscriber" />
    I can call the method, but I need a way to indentify which of the
    Content "Add Subscriber" buttons on the page was clicked.

    the method is this:

    Code:
    private void addSubscriber(object sender,
    System.Web.UI.WebControls.CommandEventArgs e)
    {
    Response.Write("trace 1: " + e.CommandArgument.ToString());
    }
    Can anyone help me work out how to get some identifying value to the
    "addSubscri ber" method?


    Many thanks in advance

    Kevin




    THINGS I'VE ALREADY TRIED (though quite possible one will work with a
    little help)

    Code:
    <asp:Button ID="testBtn" runat="server" oncommand="addSubscriber"
    Text="Add Subscriber" commandargument="item<%=loopCount%>" />
    (this just passed "item<%loopCoun t %>" as a string - i.e. my
    Repsonse.Write just displayed "trace 1: item<%=loopCoun t %>"

    Code:
    <%
    testBtn.Attributes.Add("commandargument","item" + loopCount);
    %>
    <asp:Button ID="testBtn" runat="server" oncommand="addSubscriber"
    Text="Add Subscriber" />
    (this called the method, but no commandargument was seen, i.e. the
    Response.Write showed "trace 1: "

Working...