?
Solved

Two <asp:calendar> controls?

Posted on 2004-08-04
7
Medium Priority
?
816 Views
Last Modified: 2008-03-06
Ok, I find ASP.NET infuriating.  I want to put two calendar controls on a page as follows:

<form id="form1" runat="server">
    <asp:Calendar runat="server" id="calendar1" />
</form>

<form id="form2" runat="server">
    <asp:Calendar runat="server" id="calendar2" />
</form>

However, I can't do this ASP.NET only allows a single server-side <form> tag.  I had the idea of placing the calendar tags inside a single form tag like so, but it didn't work:

<form id="form" runat="server">
    <asp:Calendar runat="server" id="calendar1" />
    <asp:Calendar runat="server" id="calendar2" />
</form>

I'm trying to include a calendar on the side of a template (with a header and footer included with SSI).  I want the *content* portion of the form to be able to have server-side forms.  I don't really care how the header calendar is displayed - in other words, it doesn't have to use the calendar control.  I would be satified just drawing a calendar manually.

Does anyone have any good code for drawing a calendar in C# similar to this:
http://www.kevinroth.com/projects/examples/WriteCalendar.asp

I don't want to use any server-side controls that require a server-side form.  Ideas? Links? Code?
0
Comment
Question by:hendridm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 8

Expert Comment

by:trevorhartman
ID: 11721409
did you try just doing the calendar without the form?  The form is only required if you need viewstate for an control.

just try:
    <asp:Calendar runat="server" id="calendar1" />
    <asp:Calendar runat="server" id="calendar2" />


-Trevor
0
 
LVL 9

Expert Comment

by:glsac
ID: 11723124
0
 
LVL 8

Author Comment

by:hendridm
ID: 11725792
Trevor - If I remove the form tags, I get the error:
"Control 'calendar1' of type 'Calendar' must be placed inside a form tag with runat=server."

Is there a way to disable the ViewState requirement?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:Pichto
ID: 11727504
If you try this :

<form runat="server">
<asp:Calendar runat="server" id="calendar1" />
<asp:Calendar runat="server" id="calendar2" />
</form>

What do you get ?

An error or what ?

Pichto
0
 
LVL 8

Author Comment

by:hendridm
ID: 11728524
Pichto - By itself, that code works.  However, it doesn't seem to like to be split up into includes (or something in my massively complex template is borked - made possible by ASP.NET's loser support for templates).

I have something like:

=====================================

<script language="C#" runat="server">
   ... Insert code here
</script>

<!--#include file="template/header.aspx" -->

<p>Body content</p>

<!--#include file="template/footer.aspx" -->

=====================================

It's much more complex than that, but I need a calendar in the footer (requires a server side form tag) and I also may need a server-side form tag in the body content.  I've tried placing the <form> tag within the include files, and before and after them but it complains.

I think perhaps I will just use a IFRAME to do it.  Much simpler, albeit less elegant, and I avoid any conflicts.

Thanks,
Dan
0
 
LVL 8

Expert Comment

by:trevorhartman
ID: 11728770
can you open the form tag in the header and close it in the footer?  or open in the body content and close it in the footer?

what if you used a #exec instead of an include?  just a thought..

-Trevor
0
 
LVL 4

Accepted Solution

by:
Pichto earned 2000 total points
ID: 11733562
You could maybe transform your header and footer in some asmx component...

Then, in your main page :
<%@ Page Language="C#" ContentType="text/html" Inherits="yourcodebehind"%>
<%@ Register TagPrefix="yourtag" Assembly="yourassembly" Namespace="yournamespace" %>

<form runat="server">
<yourtag:header runat="server"/>
some lines, tags, web-controls,  etc...
<yourtag:footer runat="server"/>
</form>


Here you can find some links on components :

http://www.microsoft.com/mspress/books/5728.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcondevelopingwebformscontrols.asp
http://www.dotnetjunkies.com/Tutorial/6B5037F8-C349-4635-BFE3-5409F6B9BE11.dcik

HTH

Pichto
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month11 days, 20 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question