Adding image buttons to web page programmatically

Discussion in 'ASP .Net' started by Leon, Feb 10, 2010.

  1. Leon

    Leon Guest

    Hi everybody.

    I am adding image buttons to web page programmatically. In each image button
    I show the product info. When user clicks any button I want to pass the
    product info to use it when the form is reposted. Can anyone tell me how to
    do it. Whatever I try is not working for me.

    Thank you in advance
     
    Leon, Feb 10, 2010
    #1
    1. Advertising

  2. Leon

    ton Guest

    if you add controls at runtime you would have to add a button.click
    procedure to your app. (I suppoose you've done so)
    But you have to be sure that these buttons are their after the postback.
    These buttons are no static controls. In your form_load procedure you have
    to add these buttons again and again. If the number of buttons depends on
    the click event in an earlier stage, you have to save this state (or the
    result of that event) so the same buttons are added again and the
    button.clck event can run.

    succes

    Ton


    "Leon" <> schreef in bericht
    news:D...
    > Hi everybody.
    >
    > I am adding image buttons to web page programmatically. In each image
    > button
    > I show the product info. When user clicks any button I want to pass the
    > product info to use it when the form is reposted. Can anyone tell me how
    > to
    > do it. Whatever I try is not working for me.
    >
    > Thank you in advance
     
    ton, Feb 11, 2010
    #2
    1. Advertising

  3. Leon

    Leon Guest

    Ton, thanks for your reply.
    Actually I added onclientclick and put a small java function to save the
    product information, but then I am getting an error message. I'll post the
    message. Please look at my next post.

    "ton" wrote:

    > if you add controls at runtime you would have to add a button.click
    > procedure to your app. (I suppoose you've done so)
    > But you have to be sure that these buttons are their after the postback.
    > These buttons are no static controls. In your form_load procedure you have
    > to add these buttons again and again. If the number of buttons depends on
    > the click event in an earlier stage, you have to save this state (or the
    > result of that event) so the same buttons are added again and the
    > button.clck event can run.
    >
    > succes
    >
    > Ton
    >
    >
    > "Leon" <> schreef in bericht
    > news:D...
    > > Hi everybody.
    > >
    > > I am adding image buttons to web page programmatically. In each image
    > > button
    > > I show the product info. When user clicks any button I want to pass the
    > > product info to use it when the form is reposted. Can anyone tell me how
    > > to
    > > do it. Whatever I try is not working for me.
    > >
    > > Thank you in advance

    >
    > .
    >
     
    Leon, Feb 11, 2010
    #3
  4. Leon,

    When adding buttons dynamically you have to recreate the buttons on
    post-back in order for their events to be able to hook up.

    I have an example of how to use dynamic controls on my website here:

    http://www.aboutfortunate.com/Code-Repository.aspx?entryid=42

    The example creates text boxes dynamically, but you'll get the idea. One
    other thing - you can run into strange issues on post back of dynamically
    created buttons if you haven't assigned an id to them. In your code behind
    when each button is created make certain to also assign it's id:
    MyDynamicButton.ID = "DynamicButton" & ButtonCount.ToString() or something
    like that will work (assuming the buttons are being created in a loop).

    --


    Sincerely,

    S. Justin Gengo, MCP

    Free code library at:
    http://www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche

    "Leon" <> wrote in message
    news:D...
    > Hi everybody.
    >
    > I am adding image buttons to web page programmatically. In each image
    > button
    > I show the product info. When user clicks any button I want to pass the
    > product info to use it when the form is reposted. Can anyone tell me how
    > to
    > do it. Whatever I try is not working for me.
    >
    > Thank you in advance
     
    S. Justin Gengo, Feb 12, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QmVu?=

    Image Buttons/Buttons not responding

    =?Utf-8?B?QmVu?=, Jul 6, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    450
    Teemu Keiski
    Jul 6, 2005
  2. Y2KYZFR1
    Replies:
    4
    Views:
    502
    Ville Vainio
    Nov 27, 2003
  3. Jonathan N. Little
    Replies:
    3
    Views:
    526
    Andy Dingley
    Apr 2, 2007
  4. Adding Controls to a Web Forms Page Programmatically

    , Mar 17, 2006, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    162
  5. Steven Choo
    Replies:
    1
    Views:
    126
    kaeli
    Feb 11, 2004
Loading...

Share This Page