Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form with calendar control

Status
Not open for further replies.

amorous

Programmer
Joined
Sep 5, 2003
Messages
1,008
Location
US
Hi Guys...

This is my first post on ASP.NET forum...

I am trying to create a form with a calendar control on it... I used one example code from the site 4guysfromrolla.com

here is my code:

Code:
<%@ Page Language="vb" %>
<script runat="server">
Private Sub Calendar1_SelectionChanged(sender As Object, e As EventArgs)
  Dim strjscript as string = "<script language=""javascript"">"
  strjscript &= "window.opener." & _
        Httpcontext.Current.Request.Querystring("formname") & ".value = '" & _
        Calendar1.SelectedDate & "';window.close();"
  strjscript = strjscript & "</script" & ">" 'Don't Ask, Tool Bug
    
  Literal1.Text = strjscript  'Set the literal control's text to the JScript code
End Sub
</script>

<form runat="server">
    <asp:Calendar id="Calendar1" runat="server" 
                     OnSelectionChanged="Calendar1_SelectionChanged" 
                     OnDayRender="Calendar1_dayrender" 
                     ShowTitle="true" DayNameFormat="FirstTwoLetters" 
                     SelectionMode="Day" BackColor="#ffffff" 
                     FirstDayOfWeek="Monday" BorderColor="#000000" 
                     ForeColor="#00000" Height="60" Width="120">
        <TitleStyle backcolor="#000080" forecolor="#ffffff" />
        <NextPrevStyle backcolor="#000080" forecolor="#ffffff" />
        <OtherMonthDayStyle forecolor="#c0c0c0" />
    </asp:Calendar>
    <asp:Literal id="Literal1" runat="server"></asp:Literal>
</form>

But when i run this i got a error page with information shown below.....

*********************
Server Error in '/' Application.
--------------------------------------------------------------------------------

Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".


<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>


Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.


<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
*********************

I have no idea what this error means...

Any suggestions would be appreciated... Thanks in advance..

-VJ
 
Not looking at the Java here is a basic Web Form with the Calendar Control and code behind for selection change. This was done in Visual Studio - C#

<%@ Page language="c#" Codebehind="Testing.aspx.cs" AutoEventWireup="false" Inherits="KomputrolSoftware.Testing" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Testing</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content=" </HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:Calendar id="Calendar1" runat="server"></asp:Calendar>
</form>
</body>
</HTML>


Code Behind

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace KomputrolSoftware
{
/// <summary>
/// Summary description for Testing.
/// </summary>
public class Testing : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Calendar Calendar1;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Calendar1.SelectionChanged += new System.EventHandler(this.Calendar1_SelectionChanged);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void Calendar1_SelectionChanged(object sender, System.EventArgs e) {
// put code here
}
}
}

Hope this helps!

Hope everyone is having a great day!

Thanks - Jennifer
 
Thanks Jennifer...

But i still open for any other suggestions...

i am trying to learn ASP.net and would like to know what that error means and how can i correct it...

-VJ
 
Is the code that you listed all of your code for the page. The reason that I ask is that you didn't have any HTML tags.

The error is generic so it won't point you in the right direction.

Hope everyone is having a great day!

Thanks - Jennifer
 
Hi Jennifer...

That's all the code i have on the page that i names newcal.aspx

-VJ
 
Then you need the HTML Look at mine above.

Hope everyone is having a great day!

Thanks - Jennifer
 
What the error means is that you're seeing the default error screen for remote users. ASP.NET has an error screen that will give you more detailed information, but such information is, by default, hidden from the user because such information may sometimes be sensative (the error screen might display an error screen with a database password showing in a connection string, for example).

As the message suggested, there is a web.config file that stores application settings, "customErrors" among them. The customErrors "mode" attribute can have 3 settings:

On- No one ever sees the detailed error screens with debugging info.
Off- Everyone always sees the detailed debugging screens.
RemoteOnly- Everyone besides a person physically using the server computer cannot see the debugging screens, but a person using the server will.

In other words, since the web.config file is set up not to serve you a detailed error message, you're getting a page that simply says "there was an error", while providing no details about its nature.

If you want to find out what's going wrong, open the web.config file of the server hosting the application, and set its "customErrors" element's mode attribute to "off".

After causing the error and getting the information you want, go back and change the web.config file back.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top