473,791 Members | 3,216 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Jason's Calendar Input with ASP.NET DetailsView

6 New Member
I'm currently creating a web page in ASP.NET and would like to use Jason's Input Calendar as well. I hope someone can help me with a problem that I am facing.

I have a form where I can add new customers. Most of the fields have the following tags within the DetailsView:-
Expand|Select|Wrap|Line Numbers
  1. <asp:BoundField DataField="First Name" HeaderText="FirstName"></asp>
As for the Birth Date field, I had converted it to TemplateField. The following is the code:-
Expand|Select|Wrap|Line Numbers
  1. <asp:TemplateField ... >
  2. <InsertItemTemplate>
  3.   <asp:TextBox ID="TextBox1" runat="server" Text="" Visible="false"></asp:TextBox>
  4.   <script type="text/javascript">DateInput("BirthDate",true,"YYYYMMDD")</script>
  5. </InsertItemField>
How do i get the value of "BirthDate" into TextBox1? I'm coding in VB.

Thank you
Apr 16 '09 #1
11 5011
acoder
16,027 Recognized Expert Moderator MVP
Can you post the client-side generated code instead of the server-side code (view source in the browser).
Apr 16 '09 #2
wudever
6 New Member
I believe i need to do some coding in the Code Behind.
Veiwing code in Visual Web Developement
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="test_Default" %>
  2.  
  3. <%@ Register assembly="System.Web.DynamicData, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.DynamicData" tagprefix="cc1" %>
  4.  
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6.  
  7. <html xmlns="http://www.w3.org/1999/xhtml">
  8. <head runat="server">
  9.     <title>Testing</title>
  10.     <script type="text/javascript" src="/ebs/calendarDateInput.js"></script>
  11. </head>
  12. <body>
  13.     <form id="form1" runat="server">
  14.     <div>
  15.         <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
  16.             DataKeyNames="CandidateID" DataSourceID="ObjectDataSource1" 
  17.             DefaultMode="Insert" GridLines="None" Height="50px" Width="125px">
  18.             <FieldHeaderStyle Wrap="False" />
  19.             <Fields>
  20.                 <asp:BoundField DataField="CandidateName" HeaderText="Name:" 
  21.                     SortExpression="CandidateName">
  22.                 <ControlStyle Width="250px" />
  23.                 </asp:BoundField>
  24.                 <asp:TemplateField HeaderText="Birth Date:" SortExpression="CandidateBirthDate">
  25.                     <EditItemTemplate>
  26.                         <asp:TextBox ID="TextBox1" runat="server" 
  27.                             Text='<%# Bind("CandidateBirthDate") %>'></asp:TextBox>
  28.                     </EditItemTemplate>
  29.                     <InsertItemTemplate>
  30.                         <asp:TextBox ID="TextBox1" runat="server" 
  31.                             Text='<%# Bind("CandidateBirthDate") %>' Visible="False"></asp:TextBox>
  32.                            <script type="text/javascript">DateInput("BirthDate",true,"YYYYMMDD")</script>
  33.                     </InsertItemTemplate>
  34.                     <ItemTemplate>
  35.                         <asp:Label ID="Label1" runat="server" Text='<%# Bind("CandidateBirthDate") %>'></asp:Label>
  36.                     </ItemTemplate>
  37.                     <ControlStyle Width="100px" />
  38.                 </asp:TemplateField>
  39.                 <asp:CommandField ButtonType="Button" CancelText="Reset" InsertText="Add" 
  40.                     ShowInsertButton="True" />
  41.             </Fields>
  42.         </asp:DetailsView>
  43.         <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
  44.             InsertMethod="InsertCandidates" OldValuesParameterFormatString="original_{0}" 
  45.             SelectMethod="GetCandidates" 
  46.             TypeName="DataSet1TableAdapters.tblCandidatesTableAdapter">
  47.             <InsertParameters>
  48.                 <asp:Parameter Name="CandidateName" Type="String" />
  49.                 <asp:Parameter Name="CandidateBirthDate" Type="String" />
  50.             </InsertParameters>
  51.         </asp:ObjectDataSource>
  52.     </div>
  53.     </form>
  54. </body>
  55. </html>
  56.  
Code generated by Browser
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2.  
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head><title>
  5.     Testing
  6. </title>
  7.     <script type="text/javascript" src="/ebs/calendarDateInput.js"></script>
  8. <link href="../App_Themes/Default/StyleSheet.css" type="text/css" rel="stylesheet" /></head>
  9. <body>
  10.     <form name="form1" method="post" action="Default.aspx" id="form1">
  11. <div>
  12. <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
  13. <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
  14. <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="0vb2yGKDrJQA8HmJomdqk35fuuGN5uXWSiFsIC2rNVbCrKgyk25wu4aVnI4xogmtKyByWDRa2scEJJS4RPeacwAl8TGpGDMbitNCoEJjZtXPsA2UKI/Eawh5i+vGloXrywLxy81+tXopvrP9bEn2vyMH+BGm3ccruJFNCMEqs0M6S6nfQGdw4UU4cfoQfFVqDQeetA/Kumq0W+G0s//TBA==" />
  15. </div>
  16.  
  17. <script type="text/javascript">
  18. //<![CDATA[
  19. var theForm = document.forms['form1'];
  20. if (!theForm) {
  21.     theForm = document.form1;
  22. }
  23. function __doPostBack(eventTarget, eventArgument) {
  24.     if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
  25.         theForm.__EVENTTARGET.value = eventTarget;
  26.         theForm.__EVENTARGUMENT.value = eventArgument;
  27.         theForm.submit();
  28.     }
  29. }
  30. //]]>
  31. </script>
  32. <div>
  33.     <input type="hidden" name="__VIEWSTATEENCRYPTED" id="__VIEWSTATEENCRYPTED" value="" />
  34.     <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="Y/0ycn2sAEM1oPMnlFLymu1MRjZwBhGCr/L+Z4Ufj0PhZyyI5PpUtQStnWM6Qcgw" />
  35. </div>
  36.     <div>
  37.         <div>
  38.     <table cellspacing="0" border="0" id="DetailsView1" style="height:50px;width:125px;border-collapse:collapse;">
  39.         <tr>
  40.             <td style="white-space:nowrap;">Name:</td><td><input name="DetailsView1$ctl01" type="text" title="Name:" style="width:250px;" /></td>
  41.         </tr><tr>
  42.             <td style="white-space:nowrap;">Birth Date:</td><td>
  43.                            <script type="text/javascript">DateInput("BirthDate",true,"YYYYMMDD")</script>
  44.                     </td>
  45.         </tr><tr>
  46.             <td colspan="2"><input type="submit" name="DetailsView1$ctl02" value="Add" />&nbsp;<input type="button" value="Reset" onclick="javascript:__doPostBack('DetailsView1','Cancel$-1')" /></td>
  47.         </tr>
  48.     </table>
  49. </div>
  50.     </div>
  51.     </form>
  52. </body>
  53. </html>
  54.  
Thanks
Apr 17 '09 #3
acoder
16,027 Recognized Expert Moderator MVP
If that's the case, you'd be better off asking in the ASP.NET forum. However, note that once the page loads, server-side code doesn't run (unless using Ajax) and to interact with the page, you'll need to use JavaScript.
Apr 20 '09 #4
wudever
6 New Member
I'm currently creating a web page in ASP.NET and would like to use Jason's Input Calendar as well. I hope someone can help me with a problem that I am facing.

I have a form where I can add new customers. Most of the fields have the following tags within the DetailsView.

Expand|Select|Wrap|Line Numbers
  1. <asp:BoundField DataField="First Name" HeaderText="FirstName"></asp>
As for the Birth Date field, I had converted it to TemplateField. The following is the code:-

Expand|Select|Wrap|Line Numbers
  1. <asp:TemplateField ... > 
  2. <InsertItemTemplate> 
  3.   <asp:TextBox ID="TextBox1" runat="server" Text="" Visible="false"></asp:TextBox> 
  4.   <script type="text/javascript">DateInput("BirthDate",true,"YYYYMMDD")</script> 
  5. </InsertItemField> 
  6.  
How do i get the value of "BirthDate" into TextBox1? I'm coding in VB.

My original post can be found <snipped: no longer valid, posts have been moved into this thread>.

Thank you
Apr 20 '09 #5
Frinavale
9,735 Recognized Expert Moderator Expert
Can you please post the JASON Object that you are using for this calendar.
Specifically could you post the JavaScript/JASON code for the DateInput() function.

-Frinny
Apr 20 '09 #6
wudever
6 New Member
Jason's JavaScript Calender can be found here or here.

In classic ASP, if I have the following code:-
Expand|Select|Wrap|Line Numbers
  1. <form action="something.asp" method="get">
  2. <script type="text/javascript">DateInput("BirthDate",true)</script>
  3. <input type="submit" value="Submit" />
  4. </form>
all I need to do to get the value is to do as follows:-
Expand|Select|Wrap|Line Numbers
  1. bDate = Request.QueryString("BirthDate")
Thanks.
Apr 20 '09 #7
Frinavale
9,735 Recognized Expert Moderator Expert
Haha :)
I thought it was JASON (JSON) calendar...not a Calendar created by some guy named Jason :)

This script dynamically created HTML on the page.
It creates <select> elements for the month and the day; it creates a text box for the year; and it creates a hidden field with the current selected date.

The problem is that it's dynamically created HTML which means you cannot access it in your Server Side VB code like you would a DropDownList, or TextBox or ASP HiddenField.

You might be able to access the hidden field using the Request.Params( 'hiddenFieldID' )....

Give that a try.
If it doesn't work we can look at changing your solution to use ASP controls (like the Ajax Toolkit's Calendar control) instead of HTML elements that are not easily accessible in your VB code.
Apr 20 '09 #8
wudever
6 New Member
I found a solution to this problem.

In the
Expand|Select|Wrap|Line Numbers
  1. <InsertParameters>
tags, remove
Expand|Select|Wrap|Line Numbers
  1. <asp:TextBox ID="TextBox1" ...</asp>
and replace with the script
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">DateInput("CandidateBirthDate",true,"YYYY-MM-DD")</script>
Within the
Expand|Select|Wrap|Line Numbers
  1. <asp:OBjectDataSource ...>
tags, look for
Expand|Select|Wrap|Line Numbers
  1. <InsertParameters>
tags and replace
Expand|Select|Wrap|Line Numbers
  1. <asp:Parameter Name="CandidateBirthDate" Type="String" />
with
Expand|Select|Wrap|Line Numbers
  1. <asp:FormParameter FormField="CandidateBirthDate" Name="CandidateBirthDate" Type="String" />
I suppose it should also work with the <UpdateParamete rs>.
Apr 20 '09 #9
wudever
6 New Member
Ok, I've got another one.

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript>DateInput("BirthDate",true,"YYYY-MM-DD",DisplayDate)</script>
DisplayDate is the date to be displayed in browser.

Question:
1) How do I create variable DisplayDate?
2) How do I add value from a database to DisplayDate?

The script is still in DetailsView, in the <EditItemTempla te> tags.

Thank you.
Apr 21 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

10
2528
by: vinu | last post by:
I have a javascript file named select.js. This is a file which is use to pop up a calendar, when clicked on a calendar icon in an ASP file. have a close button in the calendar. When i click on the button, th calendar is not closing. here is the select.js file x999NS4compatible = (document.layers); var x999IE4compatible = (document.all); var x999dayabbs = ;
0
1688
by: K B | last post by:
I finally figured out how to use the Calendar Control in DetailsView edit, HOWEVER, it's awkward having the control show. My users are used to having an image to click on then bring up a pop-up Calendar Control to populate the textbox with the date. I tried the old way but couldn't get the calendar click return to function...probably not referencing the control correctly. Is there any way to hide the calendar until the user clicks on...
3
3159
by: jparlato | last post by:
I'm using the detailsview to perform edit and insert of new records via an object datasource. If an error occurs on the insert, I want to preserve the data the operator tried to input, along with my error messages. Currently, it appears that the detailsview is trying to rebind after the error, to the empty/null detail item(on insert it is null), and thus I lose all the operator's input. Can someone suggest the proper way for me to...
4
7720
by: Kjell Arne | last post by:
Hi! I have a detailsview control in a webpart with some templated fields on. I set the ValidationGroup property to som value on these fields to distinguish from other web parts on the page. However, I'm not able to set the same ValidationGroup on the submit controls on the detailsview. Those linkbuttons(update, insert) are auto generated now. 1. Is it possible to set ValidationGroup on the detailsview? 2. How would I go about...
0
2017
by: GV | last post by:
Hi all, New to developing in VS 2005 ASP 2.0 Trying to have a easy pop calender for a button on a web page. I keep getting a error message in IE6 that says: Line 69 Char 3 Error: 'this.container' is null or not an object
2
16211
by: Cas | last post by:
Hi, I use a detailsview control for inputtng data. I want to check the user input before it is sent to the database (min. /max value, not empty, only some values allowed ...). When clicking on the insertbutton, i want a warning if one or more inputs are not correct and the user must have the opportunity to correct his errors (so all the fields must remains as it). I know it exists e.g. "RequiredFieldValidator", but i can't link it to...
0
3165
by: sehguh | last post by:
Hiya Folks, I am Currently using windows xp. Also using Visual Web Developer 2005 and Microsoft Sql server 2005. The main page consists of an aspx page and a master page. The page also consists of a label control(hidden when run in browser). Also an Sql data source control connected to database tables for a photo album. Also label web control ID=UserIdValue. Also a Details View control ID=dvPictureInsert Problem is how to work out...
1
4527
by: sehguh | last post by:
Hello folks I have recently been studying a book called "sams teach yourself asp.net 2.0 in24 hours by scott mitchell. I have reached page 614 but when i tried to run an asp page called Photoadmin/default.aspx i got the following message and info. Input string was not in a correct format. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information...
0
3329
by: mathewgk80 | last post by:
HI all, I am having popup calendar Javascript code. But i dont know how it is connecting to asp.net code.. I am using asp.net,c#.net and also using 3tier architecture with master page.... I would like to get the code for connecting the javascript to asp.net page... Please help me... The javascript code is as follows..
0
9517
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10428
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10156
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9997
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5435
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.