Re: Literal Control and Onclick?

Discussion in 'ASP .Net' started by Mike Prager, Oct 14, 2003.

  1. Mike Prager

    Mike Prager Guest

    Natty,

    Sorry to bug you again. For some reason, the event handler does not get
    raised when the linkbutton is clicked. Anything in particulat I should look
    for?

    Thx

    Mike

    "Natty Gur" <> wrote in message
    news:...
    > Hi,
    >
    > There is no problem to create LinkButton dynamically and add an event
    > handler. You just need to create event handler function and on page_load
    > to add the controls and attach them to the event handler using AddHanler
    > :
    >
    > private void Page_Load(object sender, System.EventArgs e)
    > {
    > for (int i=0; i< 10; i++)
    > {
    > LinkButton olb = new LinkButton();
    > olb.ID = "oLinkButton" + Convert.ToString (i);
    > olb.Text = "attachment " + Convert.ToString (i);
    > olb.CommandArgument = "file_ID or Location";
    > olb.Visible = true;
    > olb.Click += new EventHandler ( MyLinkButtonHandler);
    > // VB - AddHandler olb.Click, AddressOf MyLinkButtonHandler
    > this.Panel1.Controls.Add (olb);
    > }
    > }
    >
    > private void MyLinkButtonHandler(object sender, System.EventArgs e)
    > {
    > string clickButton = ((LinkButton)sender).ID;
    > }
    >
    > HTH
    >
    > Natty Gur[MVP]
    > Phone Numbers:
    > Office: +972-(0)9-7740261
    > Fax: +972-(0)9-7740261
    > Mobile: +972-(0)58-888377
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Mike Prager, Oct 14, 2003
    #1
    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. Replies:
    0
    Views:
    350
  2. Anonieko Ramos

    What's wrong with rpc-literal? Why use doc-literal?

    Anonieko Ramos, Sep 27, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    409
    Anonieko Ramos
    Sep 27, 2004
  3. bob
    Replies:
    3
    Views:
    237
  4. Replies:
    2
    Views:
    280
  5. Replies:
    4
    Views:
    210
Loading...

Share This Page