473,320 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to pass argument in image button's click handler

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
}

Mar 7 '07 #1
1 5944
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.

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"TarDuk a memory beyond the life" <ta*************@gmail.comwrote in
message news:11**********************@q40g2000cwq.googlegr oups.com...
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
}

Mar 7 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Csaba2000 | last post by:
I want to be able to programatically click on the center of an <INPUT type=image ...> element (I only care about IE 5.5+). This should work regardless of whether IE has focus. Normally you would...
6
by: WJ | last post by:
Is there a way to specify background image for an Aspx page at runtime in c# ? I clicked on the Web form in the IDE (Vs.Net 2003) and it shows "DOCUMENT", which is not accessible inside code behind...
6
by: WJ | last post by:
Is there a way to specify background image for an Aspx page at runtime in c# ? I clicked on the Web form in the IDE (Vs.Net 2003) and it shows "DOCUMENT", which is not accessible inside code behind...
24
by: =?Utf-8?B?U3dhcHB5?= | last post by:
Can anyone suggest me to pass more parameters other than two parameter for events like the following? Event: Onbutton_click(object sender, EventArgs e)" Event handler: button.Click += new...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.