adding Button question

K

Kevin Blount

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 subscriber> (e-mail address removed)
<checkbox for subscriber> (e-mail address removed)
<checkbox for subscriber> (e-mail address removed)
<checkbox for subscriber> (e-mail address removed)
<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 subscriber> (e-mail address removed)
<checkbox for subscriber> (e-mail address removed)
<checkbox for subscriber> (e-mail address removed)
<checkbox for subscriber> (e-mail address removed)
<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
"addSubscriber" 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<%loopCount %>" as a string - i.e. my
Repsonse.Write just displayed "trace 1: item<%=loopCount %>"

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: "
 

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,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top