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
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 8 10766
why dont you just place a label where you want the link and then output the html for the link to it
mylabel.text="<a href=alink.aspx?qry>click here </a>
or to this your way probably need to use the grid control so can use a bubble event to action the click from one of the link button
Hi, Simon
Try add WithEvents in the definition
Dim WithEvents ctrl As New LinkButto
Bin Song, MCP
Hi, Simon,
You should add the control independant on IsPostBack. i.e.:
"simon" <si*********@stud-moderna.si> wrote in message
news:uw*************@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
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" <de*******@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl... Hi, Simon,
You should add the control independant on IsPostBack. i.e.:
"simon" <si*********@stud-moderna.si> wrote in message news:uw*************@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
Hi, Simon,
See inline
"simon" <si*********@stud-moderna.si> wrote in message
news:#v*************@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?
For me it is easier to have the linkbutton and "the other thing" ready. Just
set their visibilities and properties. But maybe in your case it is
something more complex, so if it works this way - fine.
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.
If the panel is Visible = false, it and all its child controls are not
rendered to the client, so there will be no load.
On the button click load the DropDownList with the values and set the panel
Visible=true. Then on the DropDownList SelectedIndexChanged event set it
Visible = false again.
Hope this helps
Martin
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" <de*******@hotmail.com> wrote in message news:%2***************@TK2MSFTNGP09.phx.gbl... Hi, Simon,
You should add the control independant on IsPostBack. i.e.:
"simon" <si*********@stud-moderna.si> wrote in message news:uw*************@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
Simon,
When you place a control on a page dynamically and that control posts back
you need to re-create the control.
If the control doesn't exist then none of it's event code will fire.
Simply take your link button out of the IsPostBack if/then and your code
will work.
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"simon" <si*********@stud-moderna.si> wrote in message
news:uw*************@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
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
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" <si*********@stud-moderna.si> wrote in message
news:%2***************@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" <de*******@hotmail.com> wrote in message news:%2***************@TK2MSFTNGP09.phx.gbl... Hi, Simon,
You should add the control independant on IsPostBack. i.e.:
"simon" <si*********@stud-moderna.si> wrote in message news:uw*************@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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: RobG |
last post by:
I am trying to dynamically add an onclick to an element,
however I just can't get the syntax right. consider the
following function:
function doClick (evt,x) {
// do things with evt and x
}
...
|
by: simon |
last post by:
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 =...
|
by: hb |
last post by:
Hi,
When I add an asp:button (ex: id=btnLog) on home.aspx,
I need to create btnLog_Click() event in home.aspx.cs,
and also link this event and the button in OnInit() method
by adding:...
|
by: djc |
last post by:
On the page_load event I am querying a database and binding data to some
text boxes, list boxes, and a repeater control. When the page loads it uses
the value of one of the database fields (status)...
|
by: vj |
last post by:
How i can populate all fileds dynamically in jsp page based on contents
found in xml file?
I have written jsp servlets and java class file.
i transferred automatic data from jsp to servlet then to...
|
by: vijendra |
last post by:
How i can populate all fileds dynamically in jsp page based on contents
found in xml file?I have written jsp servlets and java class file.
i transferred automatic data from jsp to servlet then to...
|
by: jmarendo |
last post by:
Hello,
After reading through the "Table Basics - DOM - Refer to table cells" example at mredkj.com , I modified the code for my own purposes. In the modified version, I create a hyperlink and...
|
by: Mark |
last post by:
Assume you want to dynamically add one to many link button controls to a web
page dynamically at run time. Each link button needs to post back and
execute code. As the link buttons are created at...
|
by: Amoril |
last post by:
I've read quite a few different message on various boards and for some
reason I'm still having trouble wrapping my head around this viewstate
maintenance and trying to get these dynamically created...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| |