473,698 Members | 2,932 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Textbox Calendar Extender in a gridview

14 New Member
Hi

I have a a gridview with a number of columns, each column has a textbox with a calendar extender attached. The problem comes when i click on the popup button, it opens a calendar for each row in the column at the same time. So if there are four rows, it will open 4 calendars.

How do i make it only open the one for the specific row i am working with?

I am very new to Ajax so i am rather confused.

Expand|Select|Wrap|Line Numbers
  1.   <asp:TemplateField HeaderText="Start Date">
  2.                                 <ItemTemplate>
  3.                                     <asp:TextBox ID="txtStartDate" runat="server" Text='<%#Container.DataItem("ConstructionStart") %>' />
  4.                                     <asp:CalendarExtender ID="txtStartDate_CalendarExtender" runat="server" 
  5.                                     Enabled="True" TargetControlID="txtStartDate" Format="d MMMM yyyy" PopupButtonID="CalImage">
  6.                                     </asp:CalendarExtender>
  7.                                     <img id="CalImage" src="http://bytes.com/calImage.png" alt="Click here" /> 
  8.                                 </ItemTemplate>
  9.                             </asp:TemplateField>
  10.  
  11.  
Feb 18 '11 #1
2 14341
Frinavale
9,735 Recognized Expert Moderator Expert
When the CalendarExtende r is assigned a PopUpButtonID, the calendar will remain open until the user choose a date or until the next time that the user clicks the "button". (IE the user clicks the button control to show the calendar and has to click it again to hide the calendar).

This means that when you assign a PopUpButtonID to a CalendarExtende r, multiple calendars can be open at the same time.

Since you are using an HTML <img> element instead of an ASP.NET Image control, all of the images within your grid will be assigned the same id.

Not only will this make your page invalid (by HTML standards), but it will cause all of the calendar extenders to show at the same time since they are all assigned to the same control (ID).

The ASP.NET Image control is managed by ASP.NET. This means that each control is given a unique "ClientID" by ASP.NET so that your page remains valid and you avoid problems like this (the ClientID property is the id that is assigned the HTML element generated for the ASP.NET control).

So, all you have to do to fix this problem is the following:
Expand|Select|Wrap|Line Numbers
  1. <asp:TemplateField HeaderText="Start Date">
  2.   <ItemTemplate>
  3.     <asp:TextBox ID="txtStartDate" runat="server" Text='<%#Container.DataItem("ConstructionStart") %>' />
  4.     <asp:CalendarExtender ID="txtStartDate_CalendarExtender" runat="server" 
  5.           Enabled="True" TargetControlID="txtStartDate" Format="d MMMM yyyy" PopupButtonID="CalImage">
  6.     </asp:CalendarExtender>
  7.     <asp:Image ID="CalImage" runat="server" ImageUrl="~/Images/calImage.png" AlternateText="Click here" /> 
  8.   </ItemTemplate>
  9. </asp:TemplateField>
-Frinny
Feb 18 '11 #2
joss Perold
14 New Member
Hi Frinavale

I managed to implement what you said here, but now the problem is that it works fine for one column, but the rest it throws an error for

"The TargetControlID of 'txtPracComplet ion_CalendarExt ender' is not valid. A control with ID 'txtPracComplet ion' could not be found.
"

but the control is there, am i missing something?

Expand|Select|Wrap|Line Numbers
  1.   <Columns>           
  2.             <asp:BoundField Visible="False" />
  3.             <asp:TemplateField>
  4.                 <ItemTemplate>
  5.                     <asp:TextBox ID="txtConstStart" runat="server" Text='<%#Container.DataItem("ContractorName") %>' />
  6.                 </ItemTemplate>
  7.             </asp:TemplateField>
  8.             <asp:TemplateField HeaderText="Construction Start Date">
  9.                 <ItemTemplate>
  10.                     <asp:TextBox ID="txtConstStart" runat="server" Text='<%#Container.DataItem("ConstructionStart") %>' />
  11.                     <asp:CalendarExtender ID="txtConstStart_CalendarExtender" runat="server" PopupButtonID="CalImage" Format="d MMMM yyyy" Enabled="True" TargetControlID="txtConstStart">
  12.                     </asp:CalendarExtender>
  13.                     <asp:Image runat="server" id="CalImage" ImageUrl="../../calImage.png"  AlternateText="Click here" />
  14.                 </ItemTemplate>
  15.             </asp:TemplateField>
  16.             <asp:TemplateField HeaderText="Practical Completion Date">
  17.                 <ItemTemplate>
  18.                     <asp:TextBox ID="txtPracCompletion" runat="server" Text='<%#Container.DataItem("PracticalCompletion") %>' />
  19.                     <asp:CalendarExtender ID="txtPracCompletion_CalendarExtender" runat="server" PopupButtonID="CalImage" Format="d MMMM yyyy" Enabled="True" TargetControlID="txtPracCompletion">
  20.                     </asp:CalendarExtender>
  21.                     <asp:Image runat="server" id="CalImage" ImageUrl="../../calImage.png"  AlternateText="Click here" />
  22.                 </ItemTemplate>
  23.             </asp:TemplateField>
  24.  
  25.             </Columns>
  26.  
Mar 11 '11 #3

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

Similar topics

4
15283
by: BillE | last post by:
Can I make the Ajax calendar extender appear on top of dropdown lists instead of behind them? Thanks Bill
0
1606
by: silpa | last post by:
Hi, I have a problem with calendar extender. Example: <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
0
1204
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
I have a calendar extender that when I put it in an update panel, the formatting that I have in CSS, does not work. If I pull it out of my update panel, it looks fine. Is there something I can do to make the CSS formatting work for my calendar extender keep and the same format when inside an update panel that it has outside an update panel?
0
1336
by: dan | last post by:
Hi, I have a multi-line textbox in a gridview when in edit mode. The textbox (rendered as textarea in browser) set cols to 20 by default. I'd like the textbox to 'adjust' itself to the width of the column. There are cases when the column is much wider than the textbox. I could programmatically set cols (through Columns property) but this is not going to work. Is there a way to do that? Thanks,
2
2439
by: =?Utf-8?B?QWJoaWxhc2g=?= | last post by:
Hi, I am using AJAX calendar extender.Everything is works fine on date selection from pop up image option but when i dont select a date and click outside on the page,calender remains poped up,it doesn't hide.It hides only when date is selected.Is there any workaround for this? Thanks
2
2782
by: =?Utf-8?B?U3RldmUgQmxhaW4=?= | last post by:
Hi, I am using a calendar extender with a masked edit validator and masked editextender that provides a dropdown calendar and a text box for date entry. On the same page there are other other textboxes in the area where the calendar control appears. When the calendar control pops up the other textboxes get intermingled with the calendar control and you cannot pick a date. I saw a suggestion that this was a z-index issue but I haven't...
1
2506
by: George | last post by:
Hi, I want to ask how can I disable all the days before today in an AJAX calendar extender of a textbox so no one can select them. I use C# and VS2008 Thanks George
1
6064
by: bellgodz | last post by:
Hello, I have a text box on an .aspx page that an AJAX calendar extender is tied to. When this page is loaded the text box in question is populated with a date from a selected record. I've tried using the "SelectedValue" property of the calendar extender to populate this text box, but what happens is this text box retains the focus after the page is loaded, which causes the calendar from the calendar extender to appear. I do not want this...
1
5290
by: pvong | last post by:
Currently, my calendar extender is returning with the date value 7/31/2008. Is it possible to tell the extender to return it in this format? 2008-07-31 Please note, I'm a newbie and I'm doing this in VB.NET Thanks!
0
8611
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
9170
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...
1
6531
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
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
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
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.