Solved

Two <asp:calendar> controls?

Posted on 2004-08-04
7
795 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
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 8

Expert Comment

by:trevorhartman
Comment Utility
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
Comment Utility
0
 
LVL 8

Author Comment

by:hendridm
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 4

Expert Comment

by:Pichto
Comment Utility
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
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now