Welcome Guest Search | Active Topics | Sign In | Register

Selectionchanged server side event Options
eotan
Posted: Friday, April 30, 2010 2:07:10 PM
Rank: Newbie
Groups: Member

Joined: 4/30/2010
Posts: 3
Hi,
I have the following client side objects setup:

Code:

<eo:DatePicker ID="DatePicker1" runat="server" AutoPostBackOnSelect="True" DisabledDates="" MonthGridLineVisible="True" SelectedDates="" GridLineColor="64, 0, 0" GridLineVisible="True">
            <MonthStyle CssText="background-color:lemonchiffon;border-bottom-color:#400000;border-bottom-style:solid;border-bottom-width:2px;border-left-color:#400000;border-left-style:solid;border-left-width:2px;border-right-color:#400000;border-right-style:solid;border-right-width:2px;border-top-color:#400000;border-top-style:solid;border-top-width:2px;font-family:Candara;font-weight:bold;" />
            <TitleStyle CssText="background-color:lemonchiffon;border-bottom-color:#400000;border-bottom-style:solid;border-bottom-width:2px;border-left-color:#400000;border-left-style:solid;border-left-width:2px;border-right-color:#400000;border-right-style:solid;border-right-width:2px;border-top-color:#400000;border-top-style:solid;border-top-width:2px;" />
            <MonthTitleStyle CssText="background-color:white;border-bottom-style:solid;border-left-style:solid;border-right-style:solid;border-top-style:solid;" />
            <DayStyle CssText="border-bottom-color:red;border-left-color:red;border-right-color:red;border-top-color:red;" />
            <WeekendDayStyle CssText="color:tomato;" />
            <MonthSelectorStyle CssText="border-bottom-color:#400000;border-bottom-style:solid;border-bottom-width:2px;border-left-color:#400000;border-left-style:solid;border-left-width:2px;border-right-color:#400000;border-right-style:solid;border-right-width:2px;border-top-color:#400000;border-top-style:solid;border-top-width:2px;" />
        </eo:DatePicker>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>


and the following server side code:
Code:

Private Sub DatePicker1_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
        TextBox1.Text = DatePicker1.SelectedDate.ToString
    End Sub


But textbox's text value does not change when I select a date in the Datepicker.
eo_support
Posted: Friday, April 30, 2010 2:36:57 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

We tested your code in a blank page and it worked fine. Can you try the same and see if the problem still occurs? Make sure it does not use a master page.

Thanks!
eotan
Posted: Saturday, May 1, 2010 2:46:19 PM
Rank: Newbie
Groups: Member

Joined: 4/30/2010
Posts: 3
Hi,
I still don't see it. Do I need an import statement on the server side code? Here's the compete page;

Code:

Imports System.Data.OleDb
Imports System.Web.UI.WebControls.AccessDataSource

Imports System.Data



Partial Class DatePicker
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region


    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

       
    End Sub

    Private Sub DatePicker1_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
        TextBox1.Text = DatePicker1.SelectedDate.ToString

    End Sub

End Class


And here's the front end:
Code:

<%@ Page Language="VB" aspcompat="true" AutoEventWireup="false" CodeFile="DatePicker.aspx.vb" Inherits="DatePicker"%>

<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Calendar</title>     
</head>
<body bgcolor="#ffffe2">
    <form id="form1" runat="server">
    <div align =left> 
        <eo:DatePicker ID="DatePicker1" runat="server" AutoPostBackOnSelect="True" DisabledDates="" MonthGridLineVisible="True" SelectedDates="" GridLineColor="64, 0, 0" GridLineVisible="True">
            <MonthStyle CssText="background-color:lemonchiffon;border-bottom-color:#400000;border-bottom-style:solid;border-bottom-width:2px;border-left-color:#400000;border-left-style:solid;border-left-width:2px;border-right-color:#400000;border-right-style:solid;border-right-width:2px;border-top-color:#400000;border-top-style:solid;border-top-width:2px;font-family:Candara;font-weight:bold;" />
            <TitleStyle CssText="background-color:lemonchiffon;border-bottom-color:#400000;border-bottom-style:solid;border-bottom-width:2px;border-left-color:#400000;border-left-style:solid;border-left-width:2px;border-right-color:#400000;border-right-style:solid;border-right-width:2px;border-top-color:#400000;border-top-style:solid;border-top-width:2px;" />
            <MonthTitleStyle CssText="background-color:white;border-bottom-style:solid;border-left-style:solid;border-right-style:solid;border-top-style:solid;" />
            <DayStyle CssText="border-bottom-color:red;border-left-color:red;border-right-color:red;border-top-color:red;" />
            <WeekendDayStyle CssText="color:tomato;" />
            <MonthSelectorStyle CssText="border-bottom-color:#400000;border-bottom-style:solid;border-bottom-width:2px;border-left-color:#400000;border-left-style:solid;border-left-width:2px;border-right-color:#400000;border-right-style:solid;border-right-width:2px;border-top-color:#400000;border-top-style:solid;border-top-width:2px;" />
        </eo:DatePicker>
        &nbsp;&nbsp;
       
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
       
        </div>
    </form>
   
</body>
</html>


Thanks.
eo_support
Posted: Saturday, May 1, 2010 3:18:29 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

It appears that your DatePicker1_SelectionChanged is not hooked up to the DatePicker at all. Try add "Handles DatePicker1.SelectionChanged" at the end of your function definition (do you see Handles MyBase.Load at the end of Page_Load? That's why it gets called. Without that part it's just a regular function).

If you use Visual Studio, the easiest way for you to create an event handler is to select the control in design view, then click "Event" tab in property window, then double click the event you wish to handle. That should correctly create an empty handler for you with the correct "Handles" clause.

Thanks!
eotan
Posted: Monday, May 3, 2010 1:06:04 PM
Rank: Newbie
Groups: Member

Joined: 4/30/2010
Posts: 3
Thanks! It works now.
eo_support
Posted: Monday, May 3, 2010 1:19:06 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Glad to hear that. Thank you very much for the update!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.