473,322 Members | 1,496 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,322 software developers and data experts.

Events generation and handling within a server controls.

I'm trying to build a Server Control, it's a calendar to manage sellers
appointments (don't answer me to use and custumize Calendar Control because
unluckily it's not possible for this specific project).
A piece of my control's interface is composed of a table and in each of its
cells are stored informations about a seller, a date and a time range.
Each of these cells has to be an interactive element: I should be able to
process datas related to the clicked cell.
I've some problems joinig datas to each cell and managing events generated
from the cells within my server control:

At the moment I've implemented the table, within my Server Control, putting
an ImageButton in each cell and defining an event handler function
("DateIButton_Command" in the code below) for each ImageButton:

protected override void CreateChildControls()
{
....
for(...)
{
.....
DateIButton = new ImageButton();
DateIButton.CommandArgument = "9/12/2003";
DateIButton.Command += new CommandEventHandler(DateIButton_Command);
...
}
}

And then defining the event handler:

private void DateIButton_Command(object sender, CommandEventArgs e)
{
ExplodeDay(e.CommandArgument.ToString ());
}

The method works, but it has two great problems:
1) When I click on one of the ImageButtons and the page is posted back,
"CreateChildControls" (I use this one as rendering function, is it correct?)
is executed before than "DateIButton_Command". It's a problem because
"DateIButton_Command" sets some variables that the rendering function
"CreateChildControls" has to use in order change graphic interface's
appareance.
2)Using "DateIButton.CommandArgument" I can't assign no more than one single
string as argument for my event handler function "DateIButton_Command". And
I need to give it more than one argument.

How can I solve these problems? Am I using a wrong approach?

Another question: in .NET Calendar Control, it is possible to catch the
DayRender event to customize the rendering function of each single cell of
the calendar. Unluckily I can't use this control for my project, how can I
similarly build a Server Control which generates events which can be
caught and handled from its container?

Thanks in advance.
Luca.
Nov 18 '05 #1
2 1768
Hi,

CreateChildControls is, as its name implies, meant for child control
creation and it is called at the time child controls need to be created,
that is usually before postback data handling and at the latest at PreRender
stage. So result is that on postback it is most often (=always) called
before postback events because in fact, postback events cannot be raised
unless controls are created.

If you want to customize the rendering, do that in the Render phase of the
control, that means create the controls as normally at the
CreateChildControls and do the customizing based on parameters at PreRender
or actual Render.

About the command arguments, one way is to put them as comma or semicolon
separated into CommandArgument property.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"luca" <lu**********@NOSPAM.fastwebnet.it> wrote in message
news:GZ*******************@tornado.fastwebnet.it.. .
I'm trying to build a Server Control, it's a calendar to manage sellers
appointments (don't answer me to use and custumize Calendar Control because unluckily it's not possible for this specific project).
A piece of my control's interface is composed of a table and in each of its cells are stored informations about a seller, a date and a time range.
Each of these cells has to be an interactive element: I should be able to
process datas related to the clicked cell.
I've some problems joinig datas to each cell and managing events generated
from the cells within my server control:

At the moment I've implemented the table, within my Server Control, putting an ImageButton in each cell and defining an event handler function
("DateIButton_Command" in the code below) for each ImageButton:

protected override void CreateChildControls()
{
...
for(...)
{
.....
DateIButton = new ImageButton();
DateIButton.CommandArgument = "9/12/2003";
DateIButton.Command += new CommandEventHandler(DateIButton_Command);
...
}
}

And then defining the event handler:

private void DateIButton_Command(object sender, CommandEventArgs e)
{
ExplodeDay(e.CommandArgument.ToString ());
}

The method works, but it has two great problems:
1) When I click on one of the ImageButtons and the page is posted back,
"CreateChildControls" (I use this one as rendering function, is it correct?) is executed before than "DateIButton_Command". It's a problem because
"DateIButton_Command" sets some variables that the rendering function
"CreateChildControls" has to use in order change graphic interface's
appareance.
2)Using "DateIButton.CommandArgument" I can't assign no more than one single string as argument for my event handler function "DateIButton_Command". And I need to give it more than one argument.

How can I solve these problems? Am I using a wrong approach?

Another question: in .NET Calendar Control, it is possible to catch the
DayRender event to customize the rendering function of each single cell of
the calendar. Unluckily I can't use this control for my project, how can I
similarly build a Server Control which generates events which can be
caught and handled from its container?

Thanks in advance.
Luca.

Nov 18 '05 #2
Tank you for your explanations.
My doubt is that, with this kind of architecture, during CreateChildControls
stage I have to create more child controls than I actually need and then, in
PreRender or Render stage, renderize only the elements I actually need using
informations posted back from my buttons; I can't decide it in
CreateChildControls stage because I still not have the information I need to
do that. It's not computationally chep.

"Teemu Keiski" <jo****@aspalliance.com> ha scritto nel messaggio
news:O9**************@tk2msftngp13.phx.gbl...
Hi,

CreateChildControls is, as its name implies, meant for child control
creation and it is called at the time child controls need to be created,
that is usually before postback data handling and at the latest at PreRender stage. So result is that on postback it is most often (=always) called
before postback events because in fact, postback events cannot be raised
unless controls are created.

If you want to customize the rendering, do that in the Render phase of the
control, that means create the controls as normally at the
CreateChildControls and do the customizing based on parameters at PreRender or actual Render.

About the command arguments, one way is to put them as comma or semicolon
separated into CommandArgument property.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"luca" <lu**********@NOSPAM.fastwebnet.it> wrote in message
news:GZ*******************@tornado.fastwebnet.it.. .
I'm trying to build a Server Control, it's a calendar to manage sellers
appointments (don't answer me to use and custumize Calendar Control

because
unluckily it's not possible for this specific project).
A piece of my control's interface is composed of a table and in each of

its
cells are stored informations about a seller, a date and a time range.
Each of these cells has to be an interactive element: I should be able to process datas related to the clicked cell.
I've some problems joinig datas to each cell and managing events generated from the cells within my server control:

At the moment I've implemented the table, within my Server Control,

putting
an ImageButton in each cell and defining an event handler function
("DateIButton_Command" in the code below) for each ImageButton:

protected override void CreateChildControls()
{
...
for(...)
{
.....
DateIButton = new ImageButton();
DateIButton.CommandArgument = "9/12/2003";
DateIButton.Command += new CommandEventHandler(DateIButton_Command); ...
}
}

And then defining the event handler:

private void DateIButton_Command(object sender, CommandEventArgs e)
{
ExplodeDay(e.CommandArgument.ToString ());
}

The method works, but it has two great problems:
1) When I click on one of the ImageButtons and the page is posted back,
"CreateChildControls" (I use this one as rendering function, is it

correct?)
is executed before than "DateIButton_Command". It's a problem because
"DateIButton_Command" sets some variables that the rendering function
"CreateChildControls" has to use in order change graphic interface's
appareance.
2)Using "DateIButton.CommandArgument" I can't assign no more than one

single
string as argument for my event handler function "DateIButton_Command".

And
I need to give it more than one argument.

How can I solve these problems? Am I using a wrong approach?

Another question: in .NET Calendar Control, it is possible to catch the
DayRender event to customize the rendering function of each single cell of the calendar. Unluckily I can't use this control for my project, how can I similarly build a Server Control which generates events which can be
caught and handled from its container?

Thanks in advance.
Luca.


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Natalia DeBow | last post by:
Hi, I am working on a Windows-based client-server application. I am involved in the development of the remote client modules. I am using asynchronous delegates to obtain information from...
1
by: meng | last post by:
i have recently been interested in exploring ATL server. i have been doing development on asp.net and server controls the past 1 year or so. in ASP.NET, the Page and ALL its contained controls get...
7
by: Colin Young | last post by:
I have a UserControl that contains a calendar control. The calendar is not raising events (month navigation, date selections, etc.). I've checked that the OnSelectionChanged event has a handler...
1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
4
by: Venus | last post by:
Hello, Thanks for your reply. I understand that a control can be created dynamically in several ways: 1) using StringBuilder 2) using Controls.Add 3) using ASP PlaceHolder But this is just...
12
by: scsharma | last post by:
Hi, I am working on creating a webapplication and my design calls for creating main webform which will have menu bar on left hand side and a IFrame which will contain all the forms that are shown...
8
by: MrNobody | last post by:
If I have a control like say a drop down list and I have some kind of onSelectItem change event, is there a way to temporarily suspend the event handling (without removing the event and then...
5
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created...
1
by: Klaus Jensen | last post by:
Subject: Handling events of controls created at runtime I need to render some buttons at runtime based on a database, tie events to them, and handle the events when they fire. In Page_Load I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.