CodeVerge.Net Beta


   Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums



Zone: > Asp.Net Forum > asp.net_ajax.asp.net_ajax_ui Tags:
Item Type: Date Entered: 1/7/2008 4:06:38 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 20 Views: 2613 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
21 Items, 2 Pages 2 |< << Go >> >|
"kalahaine" <>
NewsGroup User
How to close a CalendarExtender7/17/2007 7:37:31 AM

0

 Hello,

 I'm Trying to close a CalendarExtender user the OnClientSelectionChanged property of the extender but I do not manage to achieve this.

Could you please give me a tip on how to do it.


 

 
Thanks
 

"keyboardcowboy
NewsGroup User
Re: How to close a CalendarExtender and use it with a FreeTextBox Control7/17/2007 12:54:43 PM

1

to close the calendar onClick i set this up in the code behind  

    //Hide the calendar
    protected override void OnLoad(EventArgs e)
    {
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "hideCalendar", @"function hideCalendar(cb) { cb.hide(); }", true);
        base.OnLoad(e);
    }

 and this is what the asp code looks like 

                    <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtDate"
                        OnClientDateSelectionChanged='hideCalendar'>
 
Please remember to click "Mark as Answer" on this post if it helped you.
"kalahaine" <>
NewsGroup User
Re: How to close a CalendarExtender and use it with a FreeTextBox Control7/17/2007 1:09:10 PM

0

Excellent !!!

It works great even though, despite I try, I can't understand how this works.

I'm not used to using Overloads or Overides since I'm a "beginner" in programming.

Could you please explain me how these lines work ?  I have got an idea of the way it works since I translated this from C# to VB but I'm not sure my vision is the good one.

 

Have you got any idea on why calendar extenders and validation extenders seem not to work very well together?

 And my last question will deal with the use of validation extenders with rich textboxes such as the FreeTextBox as have to use in my application. Do you know why validation controls are either not taken into account or are mysteriously thrown far away form the extended control ?

 

Thanx a lot for your answer.
 

"keyboardcowboy
NewsGroup User
Re: How to close a CalendarExtender and use it with a FreeTextBox Control7/17/2007 2:13:12 PM

-1

alright well basically that override function is telling the caledar that when you load i want you to do this code. I would overload it instead of changing the code itself because i only really want to use that code in this project, no need to have it in all my projects so overloading it this one time is fine. Then the first line there is telling the page that i want to register a new script. This script is basically the code i want to use to hide the calendar. the first part in the () checks the type, and the next part is the name of my script "hideCalendar". then i have the code that goes and actually hides the calendar.

basically the key connection you need to note here is the name of the script hideCalendar, this is how we cess our code when we want. you can see in the asp code i connect that script to an event

OnClientDateSelectionChanged='hideCalendar'

this simply tells the calendar that when someone selects a new date, goto the script called hideCalendar. Because we initiated this script on the caledar load, there is no problem finding it :)

are far as your validation question, i dont have an answer becuase ive never tried what you are describing, so I would recomend just making a new post asking that question.


Please remember to click "Mark as Answer" on this post if it helped you.
"kalahaine" <>
NewsGroup User
Re: How to close a CalendarExtender and use it with a FreeTextBox Control7/17/2007 3:23:51 PM

0

 thanx a lot, it's clearer that way.

I'll know this for the next time

 

thx 

"goldemberg" <>
NewsGroup User
Re: How to close a CalendarExtender and use it with a FreeTextBox Control7/17/2007 6:35:03 PM

0

hello

is there a way to close it without selecting a date?

i noticed that if you click on the button the first time, the calander apears and in the second time (without selecting a date) a full postback is beggining!!

thanks a lot,

"TGirgenti" <>
NewsGroup User
Re: How to close a CalendarExtender and use it with a FreeTextBox Control7/24/2007 3:17:58 PM

0

Hello Kalahaine.

I am interested in this also.  Can you please tell me how you converted this to VB?

Thanks,
Tony

"kalahaine" <>
NewsGroup User
Re: How to close a CalendarExtender and use it with a FreeTextBox Control7/24/2007 4:05:21 PM

0

if you don't know c#, you'll find converters on the web by typing c# to vb in google

 I give you the code in vb.net:

  
    Protected Overloads Overrides Sub OnLoad(ByVal e As EventArgs)
Page.ClientScript.RegisterClientScriptBlock(Me.[GetType](), "hideCalendar", "function hideCalendar(cb) { cb.hide(); }", True)
MyBase.OnLoad(e)
End Sub
 
I had not seen the question about how to close the calendar even though no date is chosen, I would also be interested in getting an answer to that question. 
 

 

"TGirgenti" <>
NewsGroup User
Re: How to close a CalendarExtender and use it with a FreeTextBox Control7/24/2007 4:28:37 PM

0

Hello Kalahaine.

Thanks for this code.  When i try it, i get this error "WebDev.WebServer.exe has encountered a problem and needs to close.  We are sorry for the inconvenience."

Where is your "Onload" event.  Is it in the page events?  I can't find an OnLoad.

Thanks,
Tony

"kalahaine" <>
NewsGroup User
Re: How to close a CalendarExtender and use it with a FreeTextBox Control7/24/2007 5:25:01 PM

0

You've probably forgotten to add this part. You have to mention the name of the function (hideCalendar') on the OnClientDateSelectionChanged event

 

<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtDate"
OnClientDateSelectionChanged='hideCalendar'>
 
"TGirgenti" <>
NewsGroup User
Re: How to close a CalendarExtender and use it with a FreeTextBox Control7/24/2007 7:02:40 PM

0

I did add that code to my calendar extender.

Thanks,
Tony

"kalahaine" <>
NewsGroup User
Re: How to close a CalendarExtender and use it with a FreeTextBox Control7/25/2007 7:03:21 AM

0

In my opinion, the error you mention doesn't come from the part of code you've added since it means you've got an issue with you server.

But I can not help you for this. 

"TGirgenti" <>
NewsGroup User
Re: How to close a CalendarExtender and use it with a FreeTextBox Control7/25/2007 4:27:10 PM

0

So i guess that means you can't answer my question of "where did you put your Onload event?"

Thanks,
Tony

"kalahaine" <>
NewsGroup User
Re: How to close a CalendarExtender and use it with a FreeTextBox Control7/26/2007 7:12:40 AM

0

 I put the OnLoad function given above in each .aspx.vb code behind page in which I have calendar extenders.

This works fine.

 Perhaps you should show us some lines of your code in order to see how you're proceeding.
 

"TGirgenti" <>
NewsGroup User
Re: How to close a CalendarExtender and use it with a FreeTextBox Control7/26/2007 1:58:55 PM

1

Hello Kalahaine.

Here is my Page_Load event from my aspx.vb code behind file and my html code.  I had to use the Page_load event because i can't find an OnLoad event in the drop down of events.

Thanks,
Tony

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Page.ClientScript.RegisterClientScriptBlock(Me.[GetType](), "hideCalendar", "function hideCalendar(cb) { cb.hide(); }", True)        MyBase.OnLoad(e)
        Me.getTruckMileageCompletedTextbox.Visible = False

        If Not Page.IsPostBack Then
            Me.startDateCalendar.Text = Today
            Me.endDateCalendar.Text = Today
        End If

    End Sub
<%@ Page Language="VB" MasterPageFile="~/AppMaster.Master" CodeFile="GetTruckMileage.aspx.vb" Inherits="GetTruckMileage" title="Coyne Web Services - Get Truck Mileage" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="mainCopy" runat="server">
    &nbsp;
    <div class="container">
            <h1>Coyne Chemical Trips and Truck Mileage
            </h1>
        <p class="teaser">
            Coyne Chemical Trips and Truck Mileage from Xatanet.
        </p>
            <br />
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
            <asp:Label ID="Label1" runat="server" Text="Start Date:"></asp:Label>
            <cc1:CalendarExtender ID="startDateCalendarExtender" runat="server" TargetControlID="startDateCalendar" OnClientDateSelectionChanged='hideCalendar'>
            </cc1:CalendarExtender>
            <asp:TextBox ID="startDateCalendar" runat="server" ></asp:TextBox>
            &nbsp; &nbsp;
            <asp:Button ID="getTruckMileageButton" Text="Get Truck Mileage" runat="server" />&nbsp;<br />
            <br />
                        &nbsp; <asp:Label ID="Label2" runat="server" Text="End Date:" ></asp:Label>
                        <asp:TextBox ID="endDateCalendar" runat="server" ></asp:TextBox>
       
            &nbsp; &nbsp;
            <cc1:CalendarExtender ID="endDateCalendarExtender" runat="server" TargetControlID="endDateCalendar" OnClientDateSelectionChanged='hideCalendar'>
            </cc1:CalendarExtender>
            <asp:Button ID="exportTripsButton" runat="server" Text="Export to HP3000" />
            <br />
            <br />
            <span id="progressMsg">
                <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="startDateCalendar"
                    ControlToValidate="endDateCalendar" ErrorMessage="End Date cannot be less than Start Date" Type="Date" Operator="GreaterThanEqual"></asp:CompareValidator>
            </span>
            <br />
            <br />
            <asp:Textbox ID="getTruckMileageCompletedTextbox" runat="server" ReadOnly="True" Width="390px" Height="150px" TextMode="MultiLine" Rows="10"></asp:Textbox>
            </ContentTemplate>
        </asp:UpdatePanel>
    <asp:UpdateProgress ID="UpdateProgressMsg" runat="server">
    <ProgressTemplate>
        <span id="progressMsg">
      Update in progress...  Please wait
      </span>
    </ProgressTemplate>
    </asp:UpdateProgress>
            <br />

</div>
<br />       

<div class="container">

<br />
    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
        <ContentTemplate>

    <asp:ObjectDataSource ID="TripsDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
        SelectMethod="GetTrips" TypeName="TripsBLL"></asp:ObjectDataSource>

    <asp:GridView ID="tripsGridView" SkinID="bigGridSkin" runat="server" AutoGenerateColumns="False" DataKeyNames="Tripno"
        DataSourceID="TripsDataSource" AllowPaging="True" AllowSorting="True" PageSize="15" EmptyDataText="There Are No Trips to Display" EnableViewState="False" CellPadding="2">
        <Columns>
            <asp:CommandField ShowSelectButton="True" SelectText="Select" >
                <ItemStyle HorizontalAlign="Center" />
            </asp:CommandField>
            <asp:BoundField DataField="Tripno" HeaderText="Trip #" ReadOnly="True" SortExpression="Tripno" >
                <ItemStyle HorizontalAlign="Center" />
            </asp:BoundField>
            <asp:BoundField DataField="Warehouse" HeaderText="Whse" SortExpression="Warehouse" >
                <ItemStyle HorizontalAlign="Center" />
            </asp:BoundField>
            <asp:BoundField DataField="Tractorno" HeaderText="Truck" SortExpression="Tractorno" >
                <ItemStyle HorizontalAlign="Center" />
            </asp:BoundField>
            <asp:BoundField DataField="Trailerno" HeaderText="Trailer" SortExpression="Trailerno" >
                <ItemStyle HorizontalAlign="Center" />
            </asp:BoundField>
            <asp:BoundField DataField="TripDate" DataFormatString="{0:d}" HeaderText="Date"
                HtmlEncode="False" SortExpression="TripDate" >
                <ItemStyle HorizontalAlign="Center" />
            </asp:BoundField>
            <asp:BoundField DataField="Stops" HeaderText="Stops" SortExpression="Stops" >
                <ItemStyle HorizontalAlign="Center" />
            </asp:BoundField>
            <asp:BoundField DataField="Weight" HeaderText="Weight" SortExpression="Weight" >
                <ItemStyle HorizontalAlign="Center" />
            </asp:BoundField>
            <asp:BoundField DataField="Hours" HeaderText="Hours" SortExpression="Hours" >
                <ItemStyle HorizontalAlign="Center" />
            </asp:BoundField>
            <asp:BoundField DataField="Tolls" HeaderText="Tolls" SortExpression="Tolls" >
                <ItemStyle HorizontalAlign="Center" />
            </asp:BoundField>
        </Columns>
    </asp:GridView>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="tripsGridView" EventName="DataBinding" />
        </Triggers>
    </asp:UpdatePanel>
    <div id="AlertDiv" class="MessageStyle">
           <span id="AlertMessage"></span>
    </div>
<br />
    &nbsp;
   


<div class="container">

<p>
    <asp:UpdatePanel ID="UpdatePanel3" runat="server">
        <ContentTemplate>
    <asp:ObjectDataSource ID="tripDetailsDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
        SelectMethod="GetTripDetailsByTripno" TypeName="TripDetailsBLL" DeleteMethod="DeleteTripDetail" InsertMethod="AddTripDetails" UpdateMethod="UpdateTripDetails">
        <SelectParameters>
            <asp:ControlParameter ControlID="tripsGridView" DefaultValue="1" Name="tripno" PropertyName="SelectedValue"
                Type="String" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="tripno" Type="String" />
            <asp:Parameter Name="state" Type="String" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="tripno" Type="String" />
            <asp:Parameter Name="state" Type="String" />
            <asp:Parameter Name="miles" Type="Decimal" />
            <asp:Parameter Name="fuel" Type="Decimal" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="tripno" Type="String" />
            <asp:Parameter Name="state" Type="String" />
            <asp:Parameter Name="miles" Type="Decimal" />
            <asp:Parameter Name="fuel" Type="Decimal" />
        </InsertParameters>
    </asp:ObjectDataSource>

    <asp:GridView ID="tripDetailsGridView" SkinID="filesSkin" runat="server" AllowPaging="True" AllowSorting="True"
        AutoGenerateColumns="False" DataKeyNames="Tripno" DataSourceID="tripDetailsDataSource" EnableViewState="False"
        EmptyDataText="Select a Trip to Display State Mileage">
        <Columns>
            <asp:BoundField DataField="Tripno" HeaderText="Trip No." ReadOnly="True" SortExpression="Tripno" >
                <ItemStyle HorizontalAlign="Center" />
            </asp:BoundField>
            <asp:BoundField DataField="StateCode" HeaderText="State" SortExpression="StateCode" >
                <ItemStyle HorizontalAlign="Center" />
            </asp:BoundField>
            <asp:BoundField DataField="Miles" HeaderText="Miles" SortExpression="Miles" >
                <ItemStyle HorizontalAlign="Center" />
            </asp:BoundField>
            <asp:BoundField DataField="Fuel" HeaderText="Fuel" SortExpression="Fuel" >
                <ItemStyle HorizontalAlign="Center" />
            </asp:BoundField>
        </Columns>
        <EmptyDataRowStyle Wrap="False" />
    </asp:GridView>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="tripsGridView" EventName="DataBinding" />
        </Triggers>
    </asp:UpdatePanel>
    &nbsp;&nbsp;<br />
        </p>
    </div>       
</div>       

</asp:Content>

"kalahaine" <>
NewsGroup User
Re: How to close a CalendarExtender and use it with a FreeTextBox Control7/26/2007 2:36:19 PM

0

 You have to make the difference between the Page_Load event and the the Override OnLoad method we're dealing with.

Indeed, you cannot call the page.ClientScript.register... on the page_Load but well on the override onLoad sub given above.

As Keyboardcowboys explained it to me, when the calendar will load, the OnLoad sub will be executed and will register the hideCalendar script that makes the calendar extender close when a date is chosen.

 So you need to put the OnLoad Sub as I gave it to you, and do whatever you want in your page_load event.
 

"kalahaine" <>
NewsGroup User
Re: How to close a CalendarExtender and use it with a FreeTextBox Control7/26/2007 2:37:43 PM

0

EDIT: Sorry, an error occured while posting.

Can a moderator delete this post ?

Thanx a lot and sorry again 

"TGirgenti" <>
NewsGroup User
Re: How to close a CalendarExtender and use it with a FreeTextBox Control7/30/2007 12:45:21 PM

0

Well.  I guess i'll never find out where to put the OnLoad event.

 

"kalahaine" <>
NewsGroup User
Re: How to close a CalendarExtender and use it with a FreeTextBox Control7/30/2007 3:53:23 PM

0

I'll not be able to be more precise. It's my last chance to help:

  

Option Strict On

Imports System.Data.SqlClient
Imports System.Data
Imports System.IO

Partial Class Intranet_Saisie_SNews
    Inherits System.Web.UI.Page

    Dim myConnexion As Data.SqlClient.SqlConnection = New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("cs").ConnectionString)

    Dim Employee As TEmployee

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load        
        If Not Session("employe") Is Nothing Then
            Employe = CType(Session("Employee"), TEmployee)
        End If
    End Sub

    'Override overloads method for calendar extenders
    Protected Overloads Overrides Sub OnLoad(ByVal e As EventArgs)
        Page.ClientScript.RegisterClientScriptBlock(Me.[GetType](), "hideCalendar", "function hideCalendar(cb) { cb.hide(); }", True)
        MyBase.OnLoad(e)
    End Sub

 end class


 I can't do better

"TGirgenti" <>
NewsGroup User
Re: How to close a CalendarExtender and use it with a FreeTextBox Control7/30/2007 5:50:02 PM

0

Kalahaine.

I'm soryy for not reading your previous post before i posted my impatient remarks.  I apologize for that.

I think i understand now.  Just put the OnLoad event in my code behind file for the page that contains the calendar extender and the OnLoad event executes the RegisterClientScriptBlock.

Thanks and please accept my apology for not paying attention.

Tony

21 Items, 2 Pages 2 |< << Go >> >|



Free Download:






   
  Privacy | Contact Us
All Times Are GMT