I feel like a big dummy (Ajax Popupextender/Detailsview/Calendar chaos)!-VBForums
Results 1 to 6 of 6

Thread: I feel like a big dummy (Ajax Popupextender/Detailsview/Calendar chaos)!

  1. #1

    Thread Starter
    Lively Member nmaccari's Avatar
    Join Date
    Mar 2002
    Posts
    67

    Unhappy I feel like a big dummy (Ajax Popupextender/Detailsview/Calendar chaos)!

    Well, I can't believe I just spent over four hours trying to get the Ajax PopupControl working when it contains a DetailsView and Calendar Ajax control in it. Basically, it worked fine in IE7 and Firefox but IE8 and Chrome would kept putting the popup control in the background.

    So, then it dawned on me, why not just create my own Ajax Calendar Control. Then, in about 20 minutes I came up with this code. I feel like such an idiot for not doing it before. I am not done the control yet so if you can see ways to improve it then let me know.

    Code:
    <%@ Control Language="VB" AutoEventWireup="false" CodeFile="CalenderTextBox.ascx.vb" Inherits="Controls_Objects_CalenderTextBox" %>
    
    
    <asp:UpdatePanel ID="updCal" runat="server">
    <ContentTemplate>
    
    <table>
        <tr>
            <td>
                <asp:TextBox ID="txtCalendar" runat="server"></asp:TextBox>
            </td>
            <td>
                <asp:ImageButton ID="btnCal" runat="server" ImageUrl="~/Images/calendar.gif" />
            </td>
            <td>
                <asp:RequiredFieldValidator ID="rfvDate" runat="server" ControlToValidate="txtCalendar"
                    Display="Dynamic" ErrorMessage="***"></asp:RequiredFieldValidator>
            </td>
            <td>
                <asp:CompareValidator ID="cvDate" runat="server" ControlToValidate="txtCalendar"
                    ErrorMessage="**" Operator="DataTypeCheck" Type="Date"></asp:CompareValidator>
            </td>
        </tr>
    </table>           
     <div style="margin-top:-2; text-align:center; position:absolute;">
                    <asp:Calendar ID="calPopUp" runat="server" Width="70px" Height="70px" 
                        BackColor="#E6E6D9"  BorderStyle="Outset" BorderWidth="1px"
                        Visible="False"  
                        ForeColor="Black" 
                        NextPrevFormat="ShortMonth" BorderColor="#666633" FirstDayOfWeek="Monday" 
                        Font-Names="arial" >
                        <TitleStyle BackColor="#CDCDB4" ForeColor="Navy" />
                        <SelectedDayStyle BackColor="White" ForeColor="Red" />
                        <TodayDayStyle BackColor="white" ForeColor="Red" />
                    </asp:Calendar>
                    
    </div>
    
    </ContentTemplate>
    </asp:UpdatePanel>
    
    
    Partial Class Controls_Objects_CalenderTextBox
        Inherits System.Web.UI.UserControl
        Public Event Show_Popup()
    
        Public Property Text() As String
            Get
                Return txtCalendar.Text
            End Get
            Set(ByVal value As String)
                txtCalendar.Text = value
    
            End Set
        End Property
    
        Protected Sub btnCal_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnCal.Click
            calPopUp.Visible = Not calPopUp.Visible
    
            If calPopUp.Visible = True Then
                If IsDate(txtCalendar.Text) Then
                    calPopUp.SelectedDate = txtCalendar.Text
                    calPopUp.VisibleDate = txtCalendar.Text
    
                End If
            End If
            RaiseEvent Show_Popup()
    
        End Sub
    
      
    
        Protected Sub calPopUp_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles calPopUp.SelectionChanged
            txtCalendar.Text = calPopUp.SelectedDate.ToShortDateString
            calPopUp.Visible = False
            RaiseEvent Show_Popup()
    
        End Sub
    
     
        Protected Sub calPopUp_VisibleMonthChanged(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MonthChangedEventArgs) Handles calPopUp.VisibleMonthChanged
            RaiseEvent Show_Popup()
    
        End Sub
    End Class
    Nick

  2. #2
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,966

    Re: I feel like a big dummy (Ajax Popupextender/Detailsview/Calendar chaos)!

    Hey,

    Thanks for sharing.

    For things like this, there is the ASP.Net CodeBank, which is a place you can drop Code Snippets, controls, etc, that you think will be useful to other people.

    If you want, I can ask a Mod to move this thread there for you.

    Gary

  3. #3

    Thread Starter
    Lively Member nmaccari's Avatar
    Join Date
    Mar 2002
    Posts
    67

    Re: I feel like a big dummy (Ajax Popupextender/Detailsview/Calendar chaos)!

    Okay. Thanks Gary.
    Nick

  4. #4
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,966

    Re: I feel like a big dummy (Ajax Popupextender/Detailsview/Calendar chaos)!

    Hey,

    So, do you want to have this thread moved?

    Gary

  5. #5

    Thread Starter
    Lively Member nmaccari's Avatar
    Join Date
    Mar 2002
    Posts
    67

    Re: I feel like a big dummy (Ajax Popupextender/Detailsview/Calendar chaos)!

    Sure. I think it makes sense to move it. Thanks.
    Nick

  6. #6
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: I feel like a big dummy (Ajax Popupextender/Detailsview/Calendar chaos)!

    Moved To The CodeBank

    Thanks for the heads up Gary!
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.