[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Two <asp:calendar> controls?

Posted on 2004-08-04
7
Medium Priority
?
817 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

649 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