6
Answers

Error Only Content controls are allowed directly in a content page that contains Content controls

Photo of Mike Jonson

Mike Jonson

13y
8.4k
1
Hello, people

Show this error. But why? I learn now asp.net, not all undestand

have this error in page default.aspx

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" 
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1"
    ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
    </div>
    </form>
</body>
</html>

and have page masterpage.master

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
       
        </asp:ContentPlaceHolder>
    </div>
    <h1>
        <asp:Label ID="lbl_main" runat="server" Text="Welcome to Cars US"></asp:Label>
&nbsp;
        <asp:AdRotator ID="myAdRotator" runat="server" AdvertisementFile="~/Ads.xml" />
    </h1>
    <p>
        &nbsp;</p>
    <p>
        &nbsp;</p>
    <p>
        <asp:Menu ID="Menu1" runat="server">
            <Items>
                <asp:MenuItem NavigateUrl="Default.aspx" Text="Home" Value="Home">
                </asp:MenuItem>
                <asp:MenuItem NavigateUrl="BuildCar.aspx" Text="Buil a car" Value="Buil a car">
                </asp:MenuItem>
                <asp:MenuItem NavigateUrl="Inventory.aspx" Text="View inventory"
                    Value="View inventory"></asp:MenuItem>
            </Items>
        </asp:Menu>
    </p>
    </form>
    <p>
        &nbsp;</p>
</body>
</html>

Please help

Answers (6)

0
Photo of shilpa sonawane
NA 8 12.5k 12y
its a desktop application(c#2008 and sql server2005).i want to update multiple tables.
0
Photo of Satyapriya Nayak
NA 53k 8m 12y
Hi Shilpa,

Try this...


App.xml file

 

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<appSettings>

                        <add key="dsn" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\EMP.mdb" />

            </appSettings>

</configuration>

 

 

 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Data.OleDb;

 

namespace Update_delete_datagridview

{

    public partial class Form1 : Form

    {

       OleDbDataAdapter oledbda;

       OleDbCommandBuilder olcb;

       DataTable dataTable;

       BindingSource bindingSource;

       string ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["dsn"];

       string str;

 

        public Form1()

        {

            InitializeComponent();

        }

 

        private void Form1_Load(object sender, EventArgs e)

        {

 

            OleDbConnection con = new OleDbConnection(ConnectionString);

            con.Open();

            str = "SELECT * FROM student";

         

            oledbda = new OleDbDataAdapter(str, con);

            olcb = new OleDbCommandBuilder(oledbda);

            dataTable = new DataTable();

            oledbda.Fill(dataTable);

            con.Close();

            bindingSource = new BindingSource();

            bindingSource.DataSource = dataTable;

            dataGridView1.DataSource = bindingSource;

            dataGridView1.Columns[0].Visible = false;

        }

 

        private void btnaddupdate_Click(object sender, EventArgs e)

        {

            try

            {

                oledbda.Update(dataTable);

            }

            catch (Exception exceptionObj)

            {

                MessageBox.Show(exceptionObj.Message.ToString());

            }

            MessageBox.Show("Records updated");

 

        }

 

        private void btndelete_Click(object sender, EventArgs e)

        {

            try

            {

                dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index);

                oledbda.Update(dataTable);

            }

            catch (Exception exceptionObj)

            {

                MessageBox.Show(exceptionObj.Message.ToString());

            }

            MessageBox.Show("Records Deleted");

        }

 

      

    }

}





Thanks
If this post helps you mark it as answer