Re: Dynamically add link button

From: S. Justin Gengo (sjgengo_at_aboutfortunate.com)
Date: 04/20/04


Date: Tue, 20 Apr 2004 09:42:52 -0500

Simon,

You may want to check out some sample code I've placed on my website.
www.aboutfortunate.com - click the "Code Library" link in the upper right
corner and then use the search box there to search for: "Dynamic Control". I
think some of the sample code will help you get some ideas of how to handle
this.

-- 
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
                            Nietzsche
"simon" <simon.zupan@stud-moderna.si> wrote in message
news:%23vlUlJuJEHA.892@TK2MSFTNGP09.phx.gbl...
> I have dataRepeater and ItemTemplate:
>
> <itemTemplate>
> <%# writeLine(0,DataBinder.Eval(Container.DataItem,
> "ts_id"),DataBinder.Eval(Container.DataItem, "timeStart"))%>
> </itemTemplate>
>
> In write line function I check if there exsists something and if it does,
I
> would like to add linkButton else something else.
> When user clicks this button some pannel will show and so on.
>
> Is there some other way?
>
> Second question.
>
> I have couple lists of codes. When user clicks the button, Iwould like to
> show this codes to him in some combo box.
> Then he choose one and codes dissapear.
>
> I can do that like combo box on panel and set panel's visibility to
> false.When user click the button set visibility to true and when choose
the
> code set visibility again to false.But that means that every time user
want
> this page all my lists must be loaded to him.That means slow page. I can
do
> that dynamically and load this scripts to him only when user click buton
or
> with javaScript and window.open method.
>
> Is there some other method?
>
> Thank you,
> Simon
>
> But dynamically, this won't work
>
> "Martin Dechev" <detcheff_@hotmail.com> wrote in message
> news:%23GodB5tJEHA.892@TK2MSFTNGP09.phx.gbl...
> > Hi, Simon,
> >
> > You should add the control independant on IsPostBack. i.e.:
> >
> > "simon" <simon.zupan@stud-moderna.si> wrote in message
> > news:uwqHAltJEHA.620@tk2msftngp13.phx.gbl...
> > > On code behind file:
> > >
> > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> > > System.EventArgs) Handles MyBase.Load
> >
> > '        If Not Page.IsPostBack Then
> >
> > >             Dim ctrl As New LinkButton
> > >             ctrl.ID = "link1"
> > >             ctrl.Text = "link create"
> > >             ctrl.CommandArgument = "myargument"
> > >             ctrl.CommandName = "mycommandname"
> > >             AddHandler ctrl.Click, AddressOf link_button_click
> > >             plcCategory.Controls.Add(ctrl)
> >
> > '         End If
> >
> > >  End Sub
> >
> > IMO a more appropriate place to dynamically add controls is the
Page_Init
> > automatic handler or overriding the protected Contsruct method.
> >
> > Hope this helps
> > Martin
> >
> > >
> > > Sub link_button_click(ByVal sender As Object, ByVal e As
> System.EventArgs)
> > >       Response.Write("test")
> > > End Sub
> > >
> > > AND page:
> > >
> > > <form id="Form1" method="post" runat="server">
> > >      <asp:PlaceHolder ID="plcCategory"
Runat="server"></asp:PlaceHolder>
> > > </form>
> > >
> > > What is wrong here?
> > > I would like to dynamically add more link buttons. Here is example for
> one
> > > and click event doesn't work.
> > > All link buttons should use link_button_click event.
> > >
> > > Thank you,
> > > Simon
> > >
> > >
> >
>
>