How to pass argument in image button's click handler

  • Thread starter TarDuk a memory beyond the life
  • Start date
T

TarDuk a memory beyond the life

I am developing a shopping cart application for jwellary designing \
now i am displaying all the product in the table dynamically.
and also show on image button as a add to cart after every item.
now when ever client clicks on the add to cart button than i want the
item id no in the button's click event's how can be it possible.

Here i show the code

System.Web.UI.WebControls.ImageButton add = new
System.Web.UI.WebControls.ImageButton();
add.CssClass = "button";
//add.CommandArgument = c.getRecord(start,
"Prod_ID").ToString();
add.ImageUrl = @"D:\Tarun\Final\Admin\Images\\addtocart4.jpg";
add.Click += new ImageClickEventHandler(btnaddprod_Click);
System.Web.UI.WebControls.Panel p = new
System.Web.UI.WebControls.Panel();
p.Controls.Add(add);


protected void btnaddprod_Click(object sender, EventArgs e)
{
//Dim cmdArg As String = CType(sender,
ImageButton).CommandArgument
//I know above line is working in VB.NET but i want same thing
in C#.NET can anybody helpme
}
 
D

David Wier

check into some of the new properties in the button control ('OnCommand',
'CommandName', and 'CommandArgument'). 'OnCommand' is used in place of the
'OnClick' property. Then, we can use any combination of 'CommandName' and
'CommandArgument' in the shared subroutine (or event handler), to process
the event.
 

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,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top