| | |
Server Error message when opening asp.net applicationm
Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
Created a form in which the user selects a item from a dropdownlist then clicks a button which in turn uses a streamwriter to open a sequential file and displays the data associated with their selection, this is a text file. When I run the solution I get this error control 'btnSubmit' of type 'Button' must be placed inside a form tag with runat=server. I have no idea how to fix this I need help. Below is all my code:
%@ Page Language="vb" AutoEventWireup="false" Codebehind="wfmStockQuotes.aspx.vb" Inherits="Ch13Ex3.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
</form>
<p style="FONT-WEIGHT: bold; FONT-FAMILY: Tahoma">
<asp:Label id="lblSymbol" style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 56px" runat="server"
Width="144px">Select Symbol</asp:Label>
<asp:Button id="btnSubmit" style="Z-INDEX: 104; LEFT: 288px; POSITION: absolute; TOP: 248px"
runat="server" Text="Submit"></asp:Button>
<asp:TextBox id="txtHistoricalPrices" style="Z-INDEX: 103; LEFT: 40px; POSITION: absolute; TOP: 160px"
runat="server" TextMode="MultiLine" Height="136px"></asp:TextBox>
<asp
ropDownList id="ddlStocks" style="Z-INDEX: 102; LEFT: 40px; POSITION: absolute; TOP: 88px" runat="server">
<asp:ListItem Value="abc">American Co.</asp:ListItem>
<asp:ListItem Value="jbb">Joe Bob's</asp:ListItem>
<asp:ListItem Value="xan">Xtra</asp:ListItem>
</asp
ropDownList>Stock Quotes</p>
</body>
</HTML>
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents lblSymbol As System.Web.UI.WebControls.Label
Protected WithEvents ddlStocks As System.Web.UI.WebControls.DropDownList
Protected WithEvents txtHistoricalPrices As System.Web.UI.WebControls.TextBox
Protected WithEvents btnSubmit As System.Web.UI.WebControls.Button
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim SR As New System.IO.StreamReader("c:\Share" & ddlStocks.SelectedValue & ".txt ")
txtHistoricalPrices.Text = SR.ReadToEnd()
End Sub
End Class
%@ Page Language="vb" AutoEventWireup="false" Codebehind="wfmStockQuotes.aspx.vb" Inherits="Ch13Ex3.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
</form>
<p style="FONT-WEIGHT: bold; FONT-FAMILY: Tahoma">
<asp:Label id="lblSymbol" style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 56px" runat="server"
Width="144px">Select Symbol</asp:Label>
<asp:Button id="btnSubmit" style="Z-INDEX: 104; LEFT: 288px; POSITION: absolute; TOP: 248px"
runat="server" Text="Submit"></asp:Button>
<asp:TextBox id="txtHistoricalPrices" style="Z-INDEX: 103; LEFT: 40px; POSITION: absolute; TOP: 160px"
runat="server" TextMode="MultiLine" Height="136px"></asp:TextBox>
<asp
ropDownList id="ddlStocks" style="Z-INDEX: 102; LEFT: 40px; POSITION: absolute; TOP: 88px" runat="server"><asp:ListItem Value="abc">American Co.</asp:ListItem>
<asp:ListItem Value="jbb">Joe Bob's</asp:ListItem>
<asp:ListItem Value="xan">Xtra</asp:ListItem>
</asp
ropDownList>Stock Quotes</p></body>
</HTML>
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents lblSymbol As System.Web.UI.WebControls.Label
Protected WithEvents ddlStocks As System.Web.UI.WebControls.DropDownList
Protected WithEvents txtHistoricalPrices As System.Web.UI.WebControls.TextBox
Protected WithEvents btnSubmit As System.Web.UI.WebControls.Button
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim SR As New System.IO.StreamReader("c:\Share" & ddlStocks.SelectedValue & ".txt ")
txtHistoricalPrices.Text = SR.ReadToEnd()
End Sub
End Class
YUP!
The server error message is telling you exactly what the problem is:
This line of code, infact all the of the the lines of code below </form> tag need to be between <form></form> tags:
And with the code you provided, they are not!
The server error message is telling you exactly what the problem is:
This line of code, infact all the of the the lines of code below </form> tag need to be between <form></form> tags:
ASP.NET Syntax (Toggle Plain Text)
<asp:Button id="btnSubmit" style="Z-INDEX: 104; LEFT: 288px; POSITION: absolute; TOP: 248px" runat="server" Text="Submit"></asp:Button>
And with the code you provided, they are not!
•
•
•
•
Originally Posted by augie0216
Created a form in which the user selects a item from a dropdownlist then clicks a button which in turn uses a streamwriter to open a sequential file and displays the data associated with their selection, this is a text file. When I run the solution I get this error control 'btnSubmit' of type 'Button' must be placed inside a form tag with runat=server. I have no idea how to fix this I need help. Below is all my code:
%@ Page Language="vb" AutoEventWireup="false" Codebehind="wfmStockQuotes.aspx.vb" Inherits="Ch13Ex3.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
</form>
<p style="FONT-WEIGHT: bold; FONT-FAMILY: Tahoma">
<asp:Label id="lblSymbol" style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 56px" runat="server"
Width="144px">Select Symbol</asp:Label>
<asp:Button id="btnSubmit" style="Z-INDEX: 104; LEFT: 288px; POSITION: absolute; TOP: 248px"
runat="server" Text="Submit"></asp:Button>
<asp:TextBox id="txtHistoricalPrices" style="Z-INDEX: 103; LEFT: 40px; POSITION: absolute; TOP: 160px"
runat="server" TextMode="MultiLine" Height="136px"></asp:TextBox>
<aspropDownList id="ddlStocks" style="Z-INDEX: 102; LEFT: 40px; POSITION: absolute; TOP: 88px" runat="server">
<asp:ListItem Value="abc">American Co.</asp:ListItem>
<asp:ListItem Value="jbb">Joe Bob's</asp:ListItem>
<asp:ListItem Value="xan">Xtra</asp:ListItem>
</aspropDownList>Stock Quotes</p>
</body>
</HTML>
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents lblSymbol As System.Web.UI.WebControls.Label
Protected WithEvents ddlStocks As System.Web.UI.WebControls.DropDownList
Protected WithEvents txtHistoricalPrices As System.Web.UI.WebControls.TextBox
Protected WithEvents btnSubmit As System.Web.UI.WebControls.Button
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim SR As New System.IO.StreamReader("c:\Share" & ddlStocks.SelectedValue & ".txt ")
txtHistoricalPrices.Text = SR.ReadToEnd()
End Sub
End Class
![]() |
Similar Threads
- How is 3Tier architecture implemented in ASP.NET (ASP.NET)
- PHP Installation Error Message (PHP)
- SQL SERVER 2000 Login failure in ASP.NET (ASP.NET)
- cannot find server error message (Web Browsers)
- IE Cannot find Server error, spyware, hijack (Viruses, Spyware and other Nasties)
- Error creating new ASP.Net project (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: StreamReaderClass
- Next Thread: help connecting a form to a database.. error message
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax appliances asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer c# c#gridviewcolumn cac checkbox class compatible confirmationcodegeneration content contenttype countryselector courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deployment development dgv dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv forms gridview gudi homeedition iframe iis javascript jquery listbox menu mono mssql multistepregistration nameisnotdeclared news novell objects opera problem redirect registration relationaldatabases reportemail rotatepage security serializesmo.table sessionvariables silverlight smartcard smoobjects software sql sql-server ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopemnt webdevelopment webprogramming





