Re: Adding LinkButton + click Event dynamically

Discussion in 'ASP .Net' started by Felipe Garcia, Aug 28, 2003.

  1. Add the onclick to the attributes collection of the linkbutton

    ie:
    btnMyLinkButton.Attributes("onclick") = "alert('hello world');";

    HTH
    cheers

    "ElmoWatson" <> wrote in message
    news:...
    > I've got a Linkbutton successfully being added to a Placeholder:
    > objLinkButton= New System.Web.UI.WebControls.LinkButton
    > objHR= New System.Web.UI.HtmlControls.HtmlGenericControl
    > objLinkButton.ID="lbLogout"
    > objLinkButton.Font.Bold="True"
    > ph1.controls.Add(objLinkButton)
    >
    > However, I can't figure out what the syntax is for assigning an onclick
    > event for the Linkbutton - - in the tag, I'd normally put - -
    > onclick="doMySub"
    >
    > How do I add a click event (Note: I'm using Inline coding - NOT

    code-Behind)
    > in this scenario?
    >
    >

    "ElmoWatson" <> wrote in message
    news:...
    > I've got a Linkbutton successfully being added to a Placeholder:
    > objLinkButton= New System.Web.UI.WebControls.LinkButton
    > objHR= New System.Web.UI.HtmlControls.HtmlGenericControl
    > objLinkButton.ID="lbLogout"
    > objLinkButton.Font.Bold="True"
    > ph1.controls.Add(objLinkButton)
    >
    > However, I can't figure out what the syntax is for assigning an onclick
    > event for the Linkbutton - - in the tag, I'd normally put - -
    > onclick="doMySub"
    >
    > How do I add a click event (Note: I'm using Inline coding - NOT

    code-Behind)
    > in this scenario?
    >
    >
    Felipe Garcia, Aug 28, 2003
    #1
    1. Advertising

  2. Felipe Garcia

    ElmoWatson Guest

    But this is an ASP.net (VB.net) click event - - not a Javascript
    routine - - -
    I tried:
    objLinkButton.Attributes("onclick") = "doLogout"
    This doesn't work



    "Felipe Garcia" <> wrote in message
    news:%...
    > Add the onclick to the attributes collection of the linkbutton
    >
    > ie:
    > btnMyLinkButton.Attributes("onclick") = "alert('hello world');";
    >
    > HTH
    > cheers
    >
    > "ElmoWatson" <> wrote in message
    > news:...
    > > I've got a Linkbutton successfully being added to a Placeholder:
    > > objLinkButton= New System.Web.UI.WebControls.LinkButton
    > > objHR= New System.Web.UI.HtmlControls.HtmlGenericControl
    > > objLinkButton.ID="lbLogout"
    > > objLinkButton.Font.Bold="True"
    > > ph1.controls.Add(objLinkButton)
    > >
    > > However, I can't figure out what the syntax is for assigning an onclick
    > > event for the Linkbutton - - in the tag, I'd normally put - -
    > > onclick="doMySub"
    > >
    > > How do I add a click event (Note: I'm using Inline coding - NOT

    > code-Behind)
    > > in this scenario?
    > >
    > >

    > "ElmoWatson" <> wrote in message
    > news:...
    > > I've got a Linkbutton successfully being added to a Placeholder:
    > > objLinkButton= New System.Web.UI.WebControls.LinkButton
    > > objHR= New System.Web.UI.HtmlControls.HtmlGenericControl
    > > objLinkButton.ID="lbLogout"
    > > objLinkButton.Font.Bold="True"
    > > ph1.controls.Add(objLinkButton)
    > >
    > > However, I can't figure out what the syntax is for assigning an onclick
    > > event for the Linkbutton - - in the tag, I'd normally put - -
    > > onclick="doMySub"
    > >
    > > How do I add a click event (Note: I'm using Inline coding - NOT

    > code-Behind)
    > > in this scenario?
    > >
    > >

    >
    >
    ElmoWatson, Aug 28, 2003
    #2
    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. Purvi T
    Replies:
    0
    Views:
    821
    Purvi T
    Oct 19, 2004
  2. Vaibhav
    Replies:
    0
    Views:
    479
    Vaibhav
    Aug 28, 2003
  3. Chu
    Replies:
    2
    Views:
    894
    Winista
    Apr 10, 2006
  4. Max2006
    Replies:
    2
    Views:
    1,554
    Walter Wang [MSFT]
    Sep 19, 2007
  5. Jack
    Replies:
    1
    Views:
    481
Loading...

Share This Page