O
Oitne.Inside
Hello there,
We are trying to make a asp.net ajax application. For testing purposes
we have created a small program which has to create buttons who will
create more buttons when they are clicked.
Here's our code.
<%@ Page Language="VB" AutoEventWireup="true"
CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/
TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePartialRendering="true" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Always">
<ContentTemplate>
<asp:ListBox ID="ListBox1" runat="server"></
asp:ListBox>
<asp:TextBox ID="TextBox1" runat="server"></
asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button"
OnClick="Button1_Click" EnableViewState="false" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim b As New Button
b.Text = "Nieuweknop"
AddHandler b.Click, AddressOf Button1_Click
Me.UpdatePanel1.ContentTemplateContainer().Controls.Add(b)
End Sub
End Class
As you can see, when the button is clicked, it should make a new
button. This works, but when we click the same button again, nothing
happends. We think the class is being reloaded.
When we click the newly created button, the button disapperates.
Anyone got any idea what where missing?
Thanks,
Jeremy
We are trying to make a asp.net ajax application. For testing purposes
we have created a small program which has to create buttons who will
create more buttons when they are clicked.
Here's our code.
<%@ Page Language="VB" AutoEventWireup="true"
CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/
TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePartialRendering="true" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Always">
<ContentTemplate>
<asp:ListBox ID="ListBox1" runat="server"></
asp:ListBox>
<asp:TextBox ID="TextBox1" runat="server"></
asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button"
OnClick="Button1_Click" EnableViewState="false" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim b As New Button
b.Text = "Nieuweknop"
AddHandler b.Click, AddressOf Button1_Click
Me.UpdatePanel1.ContentTemplateContainer().Controls.Add(b)
End Sub
End Class
As you can see, when the button is clicked, it should make a new
button. This works, but when we click the same button again, nothing
happends. We think the class is being reloaded.
When we click the newly created button, the button disapperates.
Anyone got any idea what where missing?
Thanks,
Jeremy