Dynamically created button holding relevant data
-
Little problem involving ASP.NET, C#, ImageButtons and events I have a list of many items. These are displayed as imagebuttons, and their
NavigateUrl
property is set to'page.aspx?productID=' + item.productID
. This works just fine, but the problem is that this actually results in a redirect, when a simple postback is enough. The list of items is still displayed, and when redirect happens, it has to be retrieved again from the DB, whereas with postback it can just stay the same, and the new information is added to it. How can I fix this? Is there a way to add some data (like productID) to a button, give all the dynamic buttons the same event, so that when it is pressed, you can get the information from theobject sender
parameter in the event? Thank you
Visual Studio can't evaluate this, can you?
public object moo { __get { return moo; } __set { moo = value; } }
-
Little problem involving ASP.NET, C#, ImageButtons and events I have a list of many items. These are displayed as imagebuttons, and their
NavigateUrl
property is set to'page.aspx?productID=' + item.productID
. This works just fine, but the problem is that this actually results in a redirect, when a simple postback is enough. The list of items is still displayed, and when redirect happens, it has to be retrieved again from the DB, whereas with postback it can just stay the same, and the new information is added to it. How can I fix this? Is there a way to add some data (like productID) to a button, give all the dynamic buttons the same event, so that when it is pressed, you can get the information from theobject sender
parameter in the event? Thank you
Visual Studio can't evaluate this, can you?
public object moo { __get { return moo; } __set { moo = value; } }
If you are using ImageButton, you can use
PostbackUrl
Property of the ImageButton. It does same as theNavigateUrl
, but with aIsPostback = True
. Check it out... I have used it long time before.Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group