Professional Web Applications Themes

How do I create a Linkbutton and Event Hander on the fly ? - ASP.NET General

Hi, I am wanting to create Linkbuttons and Event Handlers on the fly. Ideally I would be able to pass the CommandName and CommandArgument to the Event Handler which in turn would pass these to a generic method for processing. I have been able to create the LinkButtons themselves on the fly. However I haven't managed to connect the to an Event Handler. Regards James....

  1. #1

    Default How do I create a Linkbutton and Event Hander on the fly ?

    Hi,

    I am wanting to create Linkbuttons and Event Handlers on the fly.

    Ideally I would be able to pass the CommandName and CommandArgument to the
    Event Handler which in turn would pass these to a generic method for
    processing.

    I have been able to create the LinkButtons themselves on the fly. However I
    haven't managed to connect the to an Event Handler.

    Regards

    James.





    James Guest

  2. #2

    Default Re: How do I create a Linkbutton and Event Hander on the fly ?

    Good question
    I would love to know the answer to this too.

    The thing is that I am not sure if dynamically created controls can be
    referenced properly in the code behind page. What i mean is if you
    dynamically created something like System.Web.UI.WebControls.TextBox
    text01; , I don't think you'll be able to get the compiler to compile when
    you try to reference text01 in your static code, similarly eventhandlers are
    attached to any particular static control on your page. So i am not sure
    what you are trying to do is possible. although it would make more sense
    that it should be possible.

    Call in the experts....

    Cheers

    J




    "James Norton-Jones" <com> wrote in message
    news:3f4095aa$0$12649$easynet.co.uk... 



    James Guest

  3. #3

    Default Re: How do I create a Linkbutton and Event Hander on the fly ?

    Have a look at my previous posting 'Programatically creating Linkbuttons but
    ....'
    Which dynamically create the controls but does not handle any events.


    "James Zhuo" <com.au> wrote in message
    news:%phx.gbl... 
    are [/ref]
    the [/ref]
    However 
    >
    >[/ref]


    James Guest

  4. #4

    Default Re: How do I create a Linkbutton and Event Hander on the fly ?

    As it turns out this is quite easy ie:

    lbButton = New LinkButton

    lbButton.Text = "Edit"

    lbButton.CommandName = lbButton.Text

    lbButton.CommandArgument = rs.Fields("Id").Value

    AddHandler lbButton.Command, AddressOf Me.LinkButton_Command

    "James Norton-Jones" <com> wrote in message
    news:3f4095aa$0$12649$easynet.co.uk... 



    James Guest

  5. #5

    Default Re: How do I create a Linkbutton and Event Hander on the fly ?

    Thanx for posting back James
    This should come in handy later on.

    Cheers

    James

    "James Norton-Jones" <com> wrote in message
    news:3f431b91$0$10779$easynet.co.uk... [/ref]
    the [/ref]
    However 
    >
    >[/ref]


    James Guest

Similar Threads

  1. datagrid linkbutton event and firefox
    By dei8fan in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: November 7th, 07:41 PM
  2. Event Hander Question
    By Chris Fink in forum ASP.NET Building Controls
    Replies: 1
    Last Post: December 9th, 01:42 PM
  3. LinkButton and Event Arguments
    By Teemu Keiski in forum ASP.NET Building Controls
    Replies: 1
    Last Post: August 20th, 05:49 PM
  4. How to create C# Dynamic Control Event Hander
    By Earl Teigrob in forum ASP.NET
    Replies: 1
    Last Post: July 9th, 06:23 PM
  5. asp.net linkbutton event not firing
    By webdad3 in forum ASP.NET Building Controls
    Replies: 1
    Last Post: July 7th, 12:11 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139