Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 15th, 2008, 05:38 AM
Registered User
 
Join Date: Oct 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default 'FormView' must be placed inside a form tag

Hi,

I am new to ASP.net and to these forums. I have read similar post but been unable to determine a workaround for my problem.

The error i am getting is:

Code:
Control 'ctl00_ContentPlaceHolder1_FormView1' of type 'FormView' must be placed inside a form tag with runat=server.
I am using a master page and wanting to display a formview from my database in the content section. Everything looks great in design view until i try to view the page.

I have checked the code and there are two tags that contain runat="Server", maybe this is the problem!?!

Code:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
Code:
<asp:FormView ID="FormView1" runat="server" DataKeyNames="fllog_ref" DataSourceID="SqlDataSource1" DefaultMode="Insert">
Whats the fix?

Ste

 
Old October 15th, 2008, 07:56 AM
Registered User
 
Join Date: Oct 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In its simplist for this also generates the error:

Code:
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="order_processing_add.aspx.vb" Inherits="order_processing_add" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="pagetitle">Order Processing Add<br />
    <asp:FormView ID="FormView1" runat="server">
    </asp:FormView>

</div>
</asp:Content>
I have removed the runat="Server" from the asp:content tag and alternatly the asp:formview but it insist they must be there. Yet they cant both be there.

Surely you can display a FormView within a ContentPlaceHolder!?!

 
Old October 15th, 2008, 08:25 AM
Registered User
 
Join Date: Oct 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

For everyone else benefit i thought i would post the solution which i have eventually figured out for myself...

I used the design view to insert my contentplaceholder but the code generated had the contenplaceholder outside of the form tags.

I moved the content within the form tags:

<form id="form1" runat="server"><asp:contentplaceholder id="ContentPlaceHolder1" runat="server"></asp:contentplaceholder></form>

And it worked!

Simple really yet its wasted a good two hours of my day!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing the content inside the div tag cheeky Pro JSP 0 April 26th, 2007 07:26 AM
DropDownList Inside FormView Problem frogosteve ASP.NET 2.0 Basics 0 April 12th, 2007 10:30 AM
Use Response object inside asp:textbox tag fizzerchris ASP.NET 1.0 and 1.1 Basics 0 August 22nd, 2006 07:24 PM
place anchor tag around bgImage inside cell?? mat41 HTML Code Clinic 4 January 26th, 2006 07:42 AM
use a JS-variable/function inside a tag cybermaarten Javascript 3 January 20th, 2005 05:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.