Web Developer 2012 Express Problem
Hello everyone,
I'm having a hard time with some simple code. When I click a run code button I get two lines of Hello World tacked onto a textbox instead of one. I step through the code and see that the output function returns to the caller and gets called again for no apparent reason. I just installed Web Developer 2012 Express yesterday and am just messing around with it to get familiar with it. So after today's problems I installed Update 3 and it's still not working properly. Is the code faulty? Anyone have any advice to get this to work? I did this in C# and VB. In C# it works fine. The problem is only with the VB version. Here's the VB Code:
Code:
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub btnRun_Click(sender As Object, e As EventArgs) Handles btnRun.Click
output("Hello World")
End Sub
Protected Sub output(value As String)
txtOutput.Text += value + Environment.NewLine
End Sub
Protected Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
txtOutput.Text = ""
End Sub
End Class
and here's the markup:
Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Programming in Viusal Basic</title>
</head>
<body>
<h1>Programming in Visual Basic</h1>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server">
<asp:TextBox ID="txtOutput" runat="server" Height="175px" TextMode="MultiLine" Width="400px"></asp:TextBox>
</asp:Panel>
<asp:Panel ID="Panel2" runat="server">
<asp:Button ID="btnRun" runat="server" Text="Run Code" Width="95px" OnClick="btnRun_Click" />
<asp:Button ID="btnClear" runat="server" Text="Clear Console" Width="107px" OnClick="btnClear_Click" />
</asp:Panel>
</div>
</form>
</body>
</html>
Re: Web Developer 2012 Express Problem
At first glance everything looks right, however your code is calling it twice....
First here...
Code:
Protected Sub btnRun_Click(sender As Object, e As EventArgs) Handles btnRun.Click
output("Hello World")
End Sub
and then again here...
Code:
<asp:Button ID="btnRun" runat="server" Text="Run Code" Width="95px" OnClick="btnRun_Click" />
Remove either one of them, and it should call the sub only once.....
Re: Web Developer 2012 Express Problem