Results 1 to 6 of 6

Thread: [RESOLVED] [2005] Dynamic control event handle problem.

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,806

    Resolved [RESOLVED] [2005] Dynamic control event handle problem.

    Hi All,

    I am creating a set of controls dynamically from a database. The controls comprise of a panel (container) an image, a link button and a label. This all works great. I have also per link button control added a handle:-

    Code:
    AddHandler MinLnk.Click, AddressOf MinLnk_Click
    This is being created for each of the link buttons created so that they all call the same MinLnk_Click event.

    As I create the controls I also store in an array a unique code for each MinLink control which is then used to show the new page when the link button is clicked on.

    My problem is I need to identify which linked button is being pressed so I can us the correct code. They all call the same MinLnk_Click event and I can't make them call a different one because this would be variable not static.

    So in brief I can create one or ten link buttons depending on what is in the database. I store per button a article code in a array. I create a click handle which calls MinLnk_Click for each of the controls. I need to identify which button is being clicked so I can use the correct article code when it reloads the default page.

    I used master page and content page and session parameters to get the correct article.

    Thanks for any help,

    Jiggy!

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,806

    Re: [2005] Dynamic control event handle problem.

    I have also noticed that when I click on the link button it does not call my sub routine.

    Now I am really stuck,

    Jiggy!

  3. #3
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: [2005] Dynamic control event handle problem.

    The Sender argument of your event handler procedure should have the reference of the control that fired that event.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,806

    Re: [2005] Dynamic control event handle problem.

    Hi Mate,

    Can you be a bit more specific. Whem I do sender. I get very little options.

    Cheers,

    Jiggy!

  5. #5
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: [2005] Dynamic control event handle problem.

    Quote Originally Posted by Jigabyte
    Hi Mate,

    Can you be a bit more specific. Whem I do sender. I get very little options.

    Cheers,

    Jiggy!
    You get very little options because sender is of type OBJECT. That is the ultimate base class of any object. You should typecast it to appropriate type so that you can do something useful with it.

    Since you know that it is a link button, we typecast it to LinkButton
    vb.net Code:
    1. Dim myLinkButton as LinkButton = CType(sender, LinkButton)
    2. 'So now you can use the myLinkButton as you would normally have used your link button.
    3. 'e.g.
    4. Response.Write(myLinkButton.ID)
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,806

    Re: [2005] Dynamic control event handle problem.

    Thank you very much mate, that works fine.

    Cheers,

    Jiggy!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width