Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
I have this content page, and, I would like to include a calendar control, so I randomly Smile | :) 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>
 
Errors
1. Error 1 Only Content controls are allowed directly in a content page that contains Content controls. c:\inetpub\wwwroot\Jon's Couch\Default.aspx 3
 
2. Warning 2 c:\inetpub\wwwroot\Jon's Couch\Diary.aspx: ASP.NET runtime error: Only Content controls are allowed directly in a content page that contains Content controls. c:\inetpub\wwwroot\Jon's Couch\Diary.aspx 5 1 http://localhost/Jon's Couch/
 
3. Warning 3 Validation (ASP.Net): Content is not supported outside 'script' or 'asp:content' regions. 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. Source code (excluding this error here.
Posted 17-Aug-10 4:44am
jon-801.4K
Edited 17-Aug-10 4:45am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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 Smile | :)
 
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 Smile | :)
  Permalink  
Comments
jon_80 at 17-Aug-10 11:32am
   
hmm...doesn't work, because I get an error reading that I need to place the calendar within <form> </form> tags, and, it seems that it is not possible to place them within a content page.
 
diary.aspx
<asp:Content ID="Content2" ContentPlaceHolderID="body" Runat="Server">
    <asp:Calendar ID="Calendar1" runat="server">

 
Error displayed when I select My Diary (lhs)
 
Server Error in '/Jon's Couch' Application.
 
Control 'ctl00_body_Calendar1' of type 'Calendar' must be placed inside a form tag with runat=server.
 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
 
Exception Details: System.Web.HttpException: Control 'ctl00_body_Calendar1' of type 'Calendar' must be placed inside a form tag with runat=server.
 
Source Error:
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
 
Stack Trace:
 

[HttpException (0x80004005): Control 'ctl00_body_Calendar1' of type 'Calendar' must be placed inside a form tag with runat=server.]
System.Web.UI.Page.VerifyRenderingInServerForm(Control control) +8689827
System.Web.UI.WebControls.Calendar.Render(HtmlTextWriter writer) +147
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Control.Render(HtmlTextWriter writer) +10
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Control.Render(HtmlTextWriter writer) +10
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Page.Render(HtmlTextWriter writer) +29
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266
 

A <form></form> tag cannot be placed within the ContentPlaceHolder, because it seems to conflict with the <form></form> tag within the MasterPage, MasterPage.master.
Al-Farooque Shubho at 17-Aug-10 11:42am
   
Well, it should work. Please do the followings:
 
1. Copy the MasterPage codes from http://www.codeproject.com/Answers/102443/newbie-navigation-problems.aspx#answer1 (The previous answer)
 
I know, you already copied. But please, copy again, because, it had a silly problem in the MasterPage code and I modified it later. You may have copied before I corrected the problem and hence you are getting the error
 
2. Then try the code that I have given here already
 
I just tested the page and the Calendar is working fine. Please let me know
jon_80 at 17-Aug-10 15:01pm
   
well it must be that my workhorse running Win XP SP3 over .NET Framework 3.5 (+3.5 SP1) doesn't like the control, coz I'm still getting the same error. What environment are you using?
Al-Farooque Shubho at 17-Aug-10 22:25pm
   
I don't think the OS and the framework should be the problem. Please send me the source code (or, upload somewhere and give link). I'll try to correct it.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
v2
Comments
TheyCallMeMrJames at 17-Aug-10 10:30am
   
can't get formatting to work...
jon_80 at 17-Aug-10 15:03pm
   
I'll see what I can figure out with text boxes, it would be nice if I could get a custom control, because actually that was my original intention; create a calendar that is linked to a database, which triggers data being loaded in a journal like fashion, however I am still thinking out how to go about it.
 
Are you using .NET 3.5 as well?
TheyCallMeMrJames at 17-Aug-10 15:19pm
   
I'm on 3.5 + 4.0 right now, depending on the day/project. Be sure to consider jQuery/jQuery UI as it will simplify a ton of your client side development. Shameless plug: have a look at my profile and check out my imported blog articles.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

And anyway, how do I get fancy custom controls, like calendars and user controls showing up within my content?
 
Confused | :confused:
  Permalink  
Comments
TheyCallMeMrJames at 17-Aug-10 15:20pm
   
jQuery and jQuery UI. http://theycallmemrjames.blogspot.com/p/aspnet-mvc-and-jquery.html
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Make sure there are no errors in your web.config file.
It sometimes happens when you are referencing an assembly in web.config and it does not exists in the bin folder
e.g. AjaxToolKit.dll
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 310
1 OriginalGriff 295
2 Afzaal Ahmad Zeeshan 224
3 Sergey Alexandrovich Kryukov 195
4 BillWoodruff 160
0 OriginalGriff 6,499
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,193
3 Manas Bhardwaj 4,657
4 Maciej Los 4,120


Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100