473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Jason's Calendar Input with ASP.NET DetailsView

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 4981
acoder
16,027 Expert Mod 8TB
Can you post the client-side generated code instead of the server-side code (view source in the browser).
Apr 16 '09 #2
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 Expert Mod 8TB
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
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 Expert Mod 8TB
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
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 Expert Mod 8TB
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
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 <UpdateParameters>.
Apr 20 '09 #9
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 <EditItemTemplate> tags.

Thank you.
Apr 21 '09 #10
acoder
16,027 Expert Mod 8TB
@Frinavale
I'd just point out that the data interchange format is called JSON (though you would probably read it as "Jason").
Apr 21 '09 #11
Frinavale
9,735 Expert Mod 8TB
Hehe it sounds all the same in my head :)
I'm not very familiar with JSON. I've only read about it and haven't actually had the chance to use it yet. I keep my eyes open for an opportunity though :)
Apr 21 '09 #12

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

Similar topics

10
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...
0
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...
3
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...
4
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....
0
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:...
2
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...
0
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...
1
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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,...
0
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...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.