Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ASP.NET Calendar Control Weird

Posted on 2004-03-24
9
Medium Priority
?
352 Views
Last Modified: 2012-06-21
OK I'm using .NET 1.1 with a calendar control.  When I put the calendar control on an .aspx it works just fine.  When I bring the calendar (exact same function in the code behind) to a user control it no longer works.  It gives me a javascript error: "Object expected".  Any idea what is going on?  Is my user control not passing the event up to the page level?
0
Comment
Question by:srobia
[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
  • 4
  • 3
  • 2
9 Comments
 
LVL 4

Expert Comment

by:locitt
ID: 10675132
when you bring the calendar control to a user control, the id of the calendar control at client side is changed as UserControlID_CalendarControlId, so if you refer to the calendar id at client side, it will cause an "object expected" error.

that's 1 possibilitym, send your code.

locitt.
0
 

Author Comment

by:srobia
ID: 10683531
here is the control code (I am using a basepage):

<form runat="server" ID="Form1" method="post">
      <table border="0" cellpadding="0" cellspacing="0">
            <tr>
                  <td valign="top" style="HEIGHT: 16px">
                        <asp:TextBox id="txtDate" runat="server" Width="100px"></asp:TextBox>
                  </td>
                  <td valign="top" style="HEIGHT: 16px">
                        <asp:Button id="btnSelect" runat="server" Text="Select"></asp:Button>
                  </td>
            </tr>
            <tr>
                  <td valign="top" colspan="2">
                        <asp:Calendar id="calDate" runat="server" Width="160px" BackColor="White"
DayNameFormat="FirstLetter" ForeColor="Black" Height="180px" Font-Size="8pt" Font-Names="Verdana" BorderColor="#999999"CellPadding="4" Visible="True" onselectionchanged="calDate_SelectionChanged"></asp:Calendar>
                  </td>
            </tr>
      </table>
</form>
<P></P>

And here is the code behind for the control:
 Protected Sub calDate_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
        Dim dtDate As System.DateTime = calDate.SelectedDate
        txtDate.Text = dtDate.ToShortDateString()
    End Sub


And here is the page (again I am using a basepage):
<%@ Register tagprefix="body" tagname="body" src="calControl.ascx" %>
      <body:body runat="Server" ID="body" NAME="body" />

Thanks!!
0
 
LVL 4

Expert Comment

by:locitt
ID: 10687643
and when do u get the error? did u click sth when the page is loaded and get error?

locitt.
0
Understanding Linux Permissions

Linux for beginners: How to view the permissions associated with files and directories and also how you can change them.

 

Author Comment

by:srobia
ID: 10688617
I get the error when I click on a date.  The page loads fine and displays the calendar.  It just doesn't work when I click on a date on the calendar.

Thanks!!
0
 
LVL 9

Expert Comment

by:msdixon
ID: 10688898
add a try / catch block around that method... what's the runtime error?

i just recreated your control, put it in a web page, and it works fine.

Protected Sub calDate_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
      Try
            Dim dtDate As System.DateTime = calDate.SelectedDate
            txtDate.Text = dtDate.ToShortDateString()
      Catch ex as Exception
            Response.Write(ex.ToString());
      End Try
End Sub
0
 

Author Comment

by:srobia
ID: 10690379
I've tried putting a breakpoint on the code, but the client side never gets to call it because it screams about the javascript error: "Object Unidentified"
0
 
LVL 9

Expert Comment

by:msdixon
ID: 10690579
sounds like you don't have the javascript files there.

for the default installation of iis you should see the following (assuming .net 1.1):
C:\Inetpub\wwwroot\aspnet_client\system_web\1_1_4322

this should have three files in it:
SmartNav.htm
SmartNav.js
WebUIValidation.js

in this instance, the SmartNav.js is the file it's looking for.
0
 
LVL 4

Accepted Solution

by:
locitt earned 500 total points
ID: 10696730
cause you use BasePage, so i might cause the problem. How about try to debug javascript with VS.NET. Try to turn on JavaScript debuging in IE's options (Tools\Options)...

I think the __doPostBack function doesnot exist in the page.

locitt.
0
 

Author Comment

by:srobia
ID: 10757773
It was the base page issue -- I just moved the code up to the page level and everything was fixed.  Thanks for the help!!
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

688 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