[error]只允许在包含内容控件的内容页面中直接使用内容控件 [英] [error] only content controls are allowed directly in a content page that contains content controls

查看:101
本文介绍了[error]只允许在包含内容控件的内容页面中直接使用内容控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个内容页面,而且,我想要包含一个日历控件,所以我随机:)尝试了下面的代码并得到了一些错误。



有任何解决方法吗?



I have this content page, and, I would like to include a calendar control, so I randomly :) tried the following, code and got a few errors.

Any workarounds, please?

<![CDATA[<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Diary.aspx.cs" Inherits="Diary" Title="Untitled Page" %>]]>

<asp:content id="Content1" contentplaceholderid="head" runat="Server" xmlns:asp="#unknown">
<asp:calendar id="Calendar1" runat="server"></asp:calendar>
//it''s a bug including the control here (VS 2008) :confused:
</asp:content>
<asp:calendar id="Calendar1" runat="server" xmlns:asp="#unknown"></asp:calendar>
<asp:content id="Content2" contentplaceholderid="body" runat="Server" xmlns:asp="#unknown">
//it''s a bug including the control here (VS 2008) :confused:
This page is still under construction.
    
</asp:content>





错误

1.错误1只允许内容控件直接在包含内容控件的内容页面中。 c:\inetpub \wwwroot \ Jon''sCouch \Default.aspx 3



2.警告2 c:\inetpub \ www.root \\ \\ Jon''s Couch \Diary.aspx:ASP.NET运行时错误:只允许内容控件直接在包含内容控件的内容页面中。 c:\inetpub \wwwroot \ Jon''s Couch \Diary.aspx 5 1 http:// localhost / Jon''s Couch /



3.警告3验证(ASP.Net):脚本或asp:content区域之外不支持内容。 c:\inetpub \wwwroot \ Jon''s Couch \Diary.aspx 5 6 http:// localhost / Jon''s Couch /



4. Jon''s Couch(ASP.NET 3.5; armani)



5.源代码(不包括此错误其他。

推荐答案

假设您已经对现有代码问题实施了修改建议,如下所述: http:// www.codeproject.com/Answers/102443/newbie-navigation-problems.aspx#answer1 [ ^ ]



修改Diary.aspx的代码如下:



Assuming that you have implemented the modification suggestion to your existing code problems as said here : http://www.codeproject.com/Answers/102443/newbie-navigation-problems.aspx#answer1[^]

Modify the code for Diary.aspx as follows:

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Diary.aspx.cs" Inherits="Diary" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="body" Runat="Server">
    <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
</asp:Content>





这应该会显示一个很好的日历浏览器:)



顺便说一下,随机编写代码和尝试不同的东西并不是学习编程和做事的正确理念。您需要首先尝试了解您要做的事情,并学习如何使用您将要使用的编程平台/工具来完成这些工作。谷歌是你最好的朋友。



祝你好运:)



This should show you a nice calendar in the browser :)

By the way, randomly writing codes and trying different things is not the correct idea of learning programming and doing things. You need to try to understand first what you are trying to do and learn how to do those with the programming platform/tool you are going to use. Google is your best friend.

Best of luck :)


您正在使用母版页。所有代码都需要包含在内容控件中。



< code>

< asp:content id =theId1runat = servercontentplaceholderid =fromMasterPage1>



<! - 将您的内容放在这里 - >



< / asp:content>



<! - 不要在这里放任何东西 - >



< asp:content id =theId2runat =servercontentplaceholderid =fromMasterPage2>



< ! - 将您的内容放在这里 - >

< / asp:content>

< / code>



如果您仍然遇到问题:

- 确保您的内容控件正确地从母版页引用内容占位符ID

- 确保您有关闭你的标签

- 简化并只试用文本框。
You''re using master pages. All code needs to be wrapped in content controls.

<code>
<asp:content id="theId1" runat="server" contentplaceholderid="fromMasterPage1">

<!-- put your content here -->

</asp:content>

<!-- don''t put anything here -->

<asp:content id="theId2" runat="server" contentplaceholderid="fromMasterPage2">

<!-- put your content here -->
</asp:content>
</code>

If you''re still having trouble:
- Make sure your content controls reference content placeholder ids from the master page correctly
- Make sure you have closing tags for your
- Simplify and just try with just text boxes.


无论如何,我如何获得花哨的自定义控件,如日历和用户控件显示我的c ontent?



:confused:
And anyway, how do I get fancy custom controls, like calendars and user controls showing up within my content?

:confused:


这篇关于[error]只允许在包含内容控件的内容页面中直接使用内容控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆