[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 819
  • Last Modified:

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?
0
hendridm
Asked:
hendridm
  • 2
  • 2
  • 2
  • +1
1 Solution
 
trevorhartmanCommented:
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
 
glsacCommented:
0
 
hendridmAuthor Commented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
PichtoCommented:
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
 
hendridmAuthor Commented:
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
 
trevorhartmanCommented:
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
 
PichtoCommented:
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

Industry Leaders: 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!

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now