Link to home
Start Free TrialLog in
Avatar of hendridm
hendridm

asked on

Two <asp:calendar> controls?

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?
Avatar of trevorhartman
trevorhartman
Flag of United States of America image

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
Avatar of hendridm
hendridm

ASKER

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?
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
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
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
ASKER CERTIFIED SOLUTION
Avatar of Pichto
Pichto
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial