473,856 Members | 1,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What is the best practice to have a user control placed multiple times on a page?

Hello,

I created a user control that has a ListBox and a RadioButtonList (and other
stuff). The idea is that I put the user control on the ASPX page multiple
times and each user control will load with different data (locations,
departments, etc.).

When I click the RadioButtonList the Event is raised on the user control and
I can consume(?) it on the ASPX page. However, I needed to give each user
control its own ID, add the "protected UserControlType userControlID" to the
declarations, and then wire each of them to an Event to get them to work or
to even recognize their ID when the Event is raised.

It works, but my understanding that this is a poor way of doing things. Is
there a better way to approach this?

Here's some of the code in the ASPX page, to recognize the Event:

private void InitializeCompo nent(){

this.Load += new
System.EventHan dler(this.Page_ Load);

ucLocation.rblC odeDescrChanged += new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);

ucDepartment.rb lCodeDescrChang ed += new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);

}

private void ChangedSelectio nUCRadioButtons (object sender, System.EventArg s
e)

{

ReLoadControls( (Selection)send er);

}

Thank you for the help.

-Gummy

Sep 13 '06 #1
9 3206
Is all you have to do is reload all the UserControls on the aspx page?

In this case, there is no need to wire up all of these controls on your
aspx page, you should defer these events into the UserControl itself.
Otherwise you have to wire up each and every event like you are doing.

If you wire the events within the UserControl, and have each of them
call a method on the aspx page to "ReloadControls " then that should do
the trick.

What advantage are you getting out of wiring the events on the aspx
page?

Maybe I'm missing something. Someone correct me if I am wrong please.

Thanks

Sean

Gummy wrote:
Hello,

I created a user control that has a ListBox and a RadioButtonList (and other
stuff). The idea is that I put the user control on the ASPX page multiple
times and each user control will load with different data (locations,
departments, etc.).

When I click the RadioButtonList the Event is raised on the user control and
I can consume(?) it on the ASPX page. However, I needed to give each user
control its own ID, add the "protected UserControlType userControlID" to the
declarations, and then wire each of them to an Event to get them to work or
to even recognize their ID when the Event is raised.

It works, but my understanding that this is a poor way of doing things. Is
there a better way to approach this?

Here's some of the code in the ASPX page, to recognize the Event:

private void InitializeCompo nent(){

this.Load += new
System.EventHan dler(this.Page_ Load);

ucLocation.rblC odeDescrChanged += new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);

ucDepartment.rb lCodeDescrChang ed += new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);

}

private void ChangedSelectio nUCRadioButtons (object sender, System.EventArg s
e)

{

ReLoadControls( (Selection)send er);

}

Thank you for the help.

-Gummy
Sep 14 '06 #2
dkode,

Thank you for responding..

I think I may have mislead you by having the
ReLoadControls( (Selection)send er) method. It should be more like
PutInNewDataBas edOnRadioButton Choices((Select ion)sender). So I am not
reloading each UserControl, they are placed statically on the page, I am
just reloading or changing the data that appears in the specific
UserControl.

Being new to this, I am not exactly sure what the difference is between
wiring up the Events in the UserControl or on the ASPX page. My assumption
is that I need to have an event in the UserControl that is raised when an
RadioButtonList is selected. Then that Event can only be recognized in the
ASPX page if I wire it, for each an every UserControl. To me, it seems like
there is a better way to do it (not that I have any clue). For example, if a
button is clicked on a UserControl, I thought the Event is raised and the
ASPX page should know that something was clicked on it and then be able to
find the specific UserControl that was clicked. All that without actually
having to manually wire each Event in the ASPX page. Maybe I am taking OOP
too far?

So if I understand you correctly, I may be doing this right. Right?

The issue, so to speak, was that I was talking to a programmer and he only
gave hints about ViewStates and other methodologies to be more in line with
proper OOP. For now, I figure it works and as I learn more I can improve
upon it.

Thanks again so much for the information.

-Gummy

"dkode" <dk****@gmail.c omwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
Is all you have to do is reload all the UserControls on the aspx page?

In this case, there is no need to wire up all of these controls on your
aspx page, you should defer these events into the UserControl itself.
Otherwise you have to wire up each and every event like you are doing.

If you wire the events within the UserControl, and have each of them
call a method on the aspx page to "ReloadControls " then that should do
the trick.

What advantage are you getting out of wiring the events on the aspx
page?

Maybe I'm missing something. Someone correct me if I am wrong please.

Thanks

Sean

Gummy wrote:
>Hello,

I created a user control that has a ListBox and a RadioButtonList (and
other
stuff). The idea is that I put the user control on the ASPX page multiple
times and each user control will load with different data (locations,
departments, etc.).

When I click the RadioButtonList the Event is raised on the user control
and
I can consume(?) it on the ASPX page. However, I needed to give each user
control its own ID, add the "protected UserControlType userControlID" to
the
declarations , and then wire each of them to an Event to get them to work
or
to even recognize their ID when the Event is raised.

It works, but my understanding that this is a poor way of doing things.
Is
there a better way to approach this?

Here's some of the code in the ASPX page, to recognize the Event:

private void InitializeCompo nent(){

this.Load += new
System.EventHa ndler(this.Page _Load);

ucLocation.rblC odeDescrChanged += new
System.EventHa ndler(this.Chan gedSelectionUCR adioButtons);

ucDepartment.r blCodeDescrChan ged += new
System.EventHa ndler(this.Chan gedSelectionUCR adioButtons);

}

private void ChangedSelectio nUCRadioButtons (object sender,
System.EventAr gs
e)

{

ReLoadControls ((Selection)sen der);

}

Thank you for the help.

-Gummy

Sep 14 '06 #3
Ok,

That gives me a better idea of what you are trying to do. Next
question:

Is the data that is changed in one UserControl change the data to be
displayed in other UserControls?

Secnario 1:
If you only need to change one UserControls data, then keep you all of
your processing within the UserControls on that level, don't bother
handling anything within the ASPX page, this will only make your
processing more complicated and unnecessary. In this sense, what you
would do is wire up the SelectedIndexCh anged event, and handle it
within the appropraite UserControl

Secnario 2:
If one change on one UserControl changes data on all/other UserControls
on the page, it depends on what type of change is taking place.

If you need to reload/modify only a couple of UserControls it might be
best to have methods in your ASPX page that one UserControl calls and
then it can change other UserControls. If you need to reload ALL the
UserControls you could have a delegate setup in your ASPX page that all
of your usercontrols can subscribe to, then when one change is made,
you could fire the delegate that would in turn call methods on other
usercontrols. (this would be the true OOP approach to your problem,
using a multicast delegate)

Heres a tutorial on multicast delegates:
http://en.csharp-online.net/index.ph...tes_and_Events
Gummy wrote:
dkode,

Thank you for responding..

I think I may have mislead you by having the
ReLoadControls( (Selection)send er) method. It should be more like
PutInNewDataBas edOnRadioButton Choices((Select ion)sender). So I am not
reloading each UserControl, they are placed statically on the page, I am
just reloading or changing the data that appears in the specific
UserControl.

Being new to this, I am not exactly sure what the difference is between
wiring up the Events in the UserControl or on the ASPX page. My assumption
is that I need to have an event in the UserControl that is raised when an
RadioButtonList is selected. Then that Event can only be recognized in the
ASPX page if I wire it, for each an every UserControl. To me, it seems like
there is a better way to do it (not that I have any clue). For example, if a
button is clicked on a UserControl, I thought the Event is raised and the
ASPX page should know that something was clicked on it and then be able to
find the specific UserControl that was clicked. All that without actually
having to manually wire each Event in the ASPX page. Maybe I am taking OOP
too far?

So if I understand you correctly, I may be doing this right. Right?

The issue, so to speak, was that I was talking to a programmer and he only
gave hints about ViewStates and other methodologies to be more in line with
proper OOP. For now, I figure it works and as I learn more I can improve
upon it.

Thanks again so much for the information.

-Gummy

"dkode" <dk****@gmail.c omwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
Is all you have to do is reload all the UserControls on the aspx page?

In this case, there is no need to wire up all of these controls on your
aspx page, you should defer these events into the UserControl itself.
Otherwise you have to wire up each and every event like you are doing.

If you wire the events within the UserControl, and have each of them
call a method on the aspx page to "ReloadControls " then that should do
the trick.

What advantage are you getting out of wiring the events on the aspx
page?

Maybe I'm missing something. Someone correct me if I am wrong please.

Thanks

Sean

Gummy wrote:
Hello,

I created a user control that has a ListBox and a RadioButtonList (and
other
stuff). The idea is that I put the user control on the ASPX page multiple
times and each user control will load with different data (locations,
departments, etc.).

When I click the RadioButtonList the Event is raised on the user control
and
I can consume(?) it on the ASPX page. However, I needed to give each user
control its own ID, add the "protected UserControlType userControlID" to
the
declarations, and then wire each of them to an Event to get them to work
or
to even recognize their ID when the Event is raised.

It works, but my understanding that this is a poor way of doing things.
Is
there a better way to approach this?

Here's some of the code in the ASPX page, to recognize the Event:

private void InitializeCompo nent(){

this.Load += new
System.EventHan dler(this.Page_ Load);

ucLocation.rblC odeDescrChanged += new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);

ucDepartment.rb lCodeDescrChang ed += new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);

}

private void ChangedSelectio nUCRadioButtons (object sender,
System.EventArg s
e)

{

ReLoadControls( (Selection)send er);

}

Thank you for the help.

-Gummy
Sep 14 '06 #4
dkode,

Once again, thanks so much for the very detailed reply and link.

It is Scenario 1. Right now when a change is made to the UserControl, I have
that event in the UserControl and it is wired up in the ASPX.

Specifically, do I need to have every single UserControl wired in the ASPX
page? In the code below, the rblCodeDescrCha nged is the Event in the
UserControl. So do I need to add the line for each UserControl (ucLocation,
ucDepartment, etc.)?

private void InitializeCompo nent(){
this.Load += new System.EventHan dler(this.Page_ Load);
ucLocation.rblC odeDescrChanged += new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);
ucDepartment.rb lCodeDescrChang ed += new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);
}

By the way, the code compiles just fine, but I do get the error saying that
the rblCodeDescrCha nged event does not exist (or something like that), when
obviously it does. Any thoughts on that?

What if I have multiple events in the UserControl? One for a button click,
one for a dropdownlistbox , do I need to wire the user control for each
event. My hope and assumption is that I can use the Delegates for that (I'll
read the link you sent).

I really appreciate you taking the time to answer my questions so
thoroughly. You have helped me so much and I've learned a great deal. Thank
you.

-Gummy
"dkode" <dk****@gmail.c omwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
Ok,

That gives me a better idea of what you are trying to do. Next
question:

Is the data that is changed in one UserControl change the data to be
displayed in other UserControls?

Secnario 1:
If you only need to change one UserControls data, then keep you all of
your processing within the UserControls on that level, don't bother
handling anything within the ASPX page, this will only make your
processing more complicated and unnecessary. In this sense, what you
would do is wire up the SelectedIndexCh anged event, and handle it
within the appropraite UserControl

Secnario 2:
If one change on one UserControl changes data on all/other UserControls
on the page, it depends on what type of change is taking place.

If you need to reload/modify only a couple of UserControls it might be
best to have methods in your ASPX page that one UserControl calls and
then it can change other UserControls. If you need to reload ALL the
UserControls you could have a delegate setup in your ASPX page that all
of your usercontrols can subscribe to, then when one change is made,
you could fire the delegate that would in turn call methods on other
usercontrols. (this would be the true OOP approach to your problem,
using a multicast delegate)

Heres a tutorial on multicast delegates:
http://en.csharp-online.net/index.ph...tes_and_Events
Gummy wrote:
>dkode,

Thank you for responding..

I think I may have mislead you by having the
ReLoadControls ((Selection)sen der) method. It should be more like
PutInNewDataBa sedOnRadioButto nChoices((Selec tion)sender). So I am not
reloading each UserControl, they are placed statically on the page, I am
just reloading or changing the data that appears in the specific
UserControl.

Being new to this, I am not exactly sure what the difference is between
wiring up the Events in the UserControl or on the ASPX page. My
assumption
is that I need to have an event in the UserControl that is raised when an
RadioButtonLis t is selected. Then that Event can only be recognized in
the
ASPX page if I wire it, for each an every UserControl. To me, it seems
like
there is a better way to do it (not that I have any clue). For example,
if a
button is clicked on a UserControl, I thought the Event is raised and the
ASPX page should know that something was clicked on it and then be able
to
find the specific UserControl that was clicked. All that without actually
having to manually wire each Event in the ASPX page. Maybe I am taking
OOP
too far?

So if I understand you correctly, I may be doing this right. Right?

The issue, so to speak, was that I was talking to a programmer and he
only
gave hints about ViewStates and other methodologies to be more in line
with
proper OOP. For now, I figure it works and as I learn more I can improve
upon it.

Thanks again so much for the information.

-Gummy

"dkode" <dk****@gmail.c omwrote in message
news:11******* *************** @h48g2000cwc.go oglegroups.com. ..
Is all you have to do is reload all the UserControls on the aspx page?

In this case, there is no need to wire up all of these controls on your
aspx page, you should defer these events into the UserControl itself.
Otherwise you have to wire up each and every event like you are doing.

If you wire the events within the UserControl, and have each of them
call a method on the aspx page to "ReloadControls " then that should do
the trick.

What advantage are you getting out of wiring the events on the aspx
page?

Maybe I'm missing something. Someone correct me if I am wrong please.

Thanks

Sean

Gummy wrote:
Hello,

I created a user control that has a ListBox and a RadioButtonList (and
other
stuff). The idea is that I put the user control on the ASPX page
multiple
times and each user control will load with different data (locations,
departments, etc.).

When I click the RadioButtonList the Event is raised on the user
control
and
I can consume(?) it on the ASPX page. However, I needed to give each
user
control its own ID, add the "protected UserControlType userControlID"
to
the
declarations , and then wire each of them to an Event to get them to
work
or
to even recognize their ID when the Event is raised.

It works, but my understanding that this is a poor way of doing
things.
Is
there a better way to approach this?

Here's some of the code in the ASPX page, to recognize the Event:

private void InitializeCompo nent(){

this.Load += new
System.EventHa ndler(this.Page _Load);

ucLocation.rblC odeDescrChanged +=
new
System.EventHa ndler(this.Chan gedSelectionUCR adioButtons);

ucDepartment.r blCodeDescrChan ged += new
System.EventHa ndler(this.Chan gedSelectionUCR adioButtons);

}

private void ChangedSelectio nUCRadioButtons (object sender,
System.EventAr gs
e)

{

ReLoadControls ((Selection)sen der);

}

Thank you for the help.

-Gummy

Sep 15 '06 #5
Ok,

If changes inside one UserControl only affect that UserControl, then
you should have no event wiring in the aspx page. Keep all of your
event related wiring within the UserControl.

In each UserControl you will have to wire the events for that
UserControl via InitializeCompo nent.

Now, for my next question,
Is each UserControl exactly the same? or all they all different?

Because if they are all the same, you can dynamically add them to the
page which would save you a great deal of time.

Gummy wrote:
dkode,

Once again, thanks so much for the very detailed reply and link.

It is Scenario 1. Right now when a change is made to the UserControl, I have
that event in the UserControl and it is wired up in the ASPX.

Specifically, do I need to have every single UserControl wired in the ASPX
page? In the code below, the rblCodeDescrCha nged is the Event in the
UserControl. So do I need to add the line for each UserControl (ucLocation,
ucDepartment, etc.)?

private void InitializeCompo nent(){
this.Load += new System.EventHan dler(this.Page_ Load);
ucLocation.rblC odeDescrChanged += new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);
ucDepartment.rb lCodeDescrChang ed += new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);
}

By the way, the code compiles just fine, but I do get the error saying that
the rblCodeDescrCha nged event does not exist (or something like that), when
obviously it does. Any thoughts on that?

What if I have multiple events in the UserControl? One for a button click,
one for a dropdownlistbox , do I need to wire the user control for each
event. My hope and assumption is that I can use the Delegates for that (I'll
read the link you sent).

I really appreciate you taking the time to answer my questions so
thoroughly. You have helped me so much and I've learned a great deal. Thank
you.

-Gummy
"dkode" <dk****@gmail.c omwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
Ok,

That gives me a better idea of what you are trying to do. Next
question:

Is the data that is changed in one UserControl change the data to be
displayed in other UserControls?

Secnario 1:
If you only need to change one UserControls data, then keep you all of
your processing within the UserControls on that level, don't bother
handling anything within the ASPX page, this will only make your
processing more complicated and unnecessary. In this sense, what you
would do is wire up the SelectedIndexCh anged event, and handle it
within the appropraite UserControl

Secnario 2:
If one change on one UserControl changes data on all/other UserControls
on the page, it depends on what type of change is taking place.

If you need to reload/modify only a couple of UserControls it might be
best to have methods in your ASPX page that one UserControl calls and
then it can change other UserControls. If you need to reload ALL the
UserControls you could have a delegate setup in your ASPX page that all
of your usercontrols can subscribe to, then when one change is made,
you could fire the delegate that would in turn call methods on other
usercontrols. (this would be the true OOP approach to your problem,
using a multicast delegate)

Heres a tutorial on multicast delegates:
http://en.csharp-online.net/index.ph...tes_and_Events
Gummy wrote:
dkode,

Thank you for responding..

I think I may have mislead you by having the
ReLoadControls( (Selection)send er) method. It should be more like
PutInNewDataBas edOnRadioButton Choices((Select ion)sender). So I am not
reloading each UserControl, they are placed statically on the page, I am
just reloading or changing the data that appears in the specific
UserControl.

Being new to this, I am not exactly sure what the difference is between
wiring up the Events in the UserControl or on the ASPX page. My
assumption
is that I need to have an event in the UserControl that is raised when an
RadioButtonList is selected. Then that Event can only be recognized in
the
ASPX page if I wire it, for each an every UserControl. To me, it seems
like
there is a better way to do it (not that I have any clue). For example,
if a
button is clicked on a UserControl, I thought the Event is raised and the
ASPX page should know that something was clicked on it and then be able
to
find the specific UserControl that was clicked. All that without actually
having to manually wire each Event in the ASPX page. Maybe I am taking
OOP
too far?

So if I understand you correctly, I may be doing this right. Right?

The issue, so to speak, was that I was talking to a programmer and he
only
gave hints about ViewStates and other methodologies to be more in line
with
proper OOP. For now, I figure it works and as I learn more I can improve
upon it.

Thanks again so much for the information.

-Gummy

"dkode" <dk****@gmail.c omwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
Is all you have to do is reload all the UserControls on the aspx page?

In this case, there is no need to wire up all of these controls on your
aspx page, you should defer these events into the UserControl itself.
Otherwise you have to wire up each and every event like you are doing.

If you wire the events within the UserControl, and have each of them
call a method on the aspx page to "ReloadControls " then that should do
the trick.

What advantage are you getting out of wiring the events on the aspx
page?

Maybe I'm missing something. Someone correct me if I am wrong please.

Thanks

Sean

Gummy wrote:
Hello,

I created a user control that has a ListBox and a RadioButtonList (and
other
stuff). The idea is that I put the user control on the ASPX page
multiple
times and each user control will load with different data (locations,
departments, etc.).

When I click the RadioButtonList the Event is raised on the user
control
and
I can consume(?) it on the ASPX page. However, I needed to give each
user
control its own ID, add the "protected UserControlType userControlID"
to
the
declarations, and then wire each of them to an Event to get them to
work
or
to even recognize their ID when the Event is raised.

It works, but my understanding that this is a poor way of doing
things.
Is
there a better way to approach this?

Here's some of the code in the ASPX page, to recognize the Event:

private void InitializeCompo nent(){

this.Load += new
System.EventHan dler(this.Page_ Load);

ucLocation.rblC odeDescrChanged +=
new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);

ucDepartment.rb lCodeDescrChang ed += new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);

}

private void ChangedSelectio nUCRadioButtons (object sender,
System.EventArg s
e)

{

ReLoadControls( (Selection)send er);

}

Thank you for the help.

-Gummy
Sep 15 '06 #6
I think they are exactly the same - sometimes.
Each one has two listboxes, an ImageButton pointing to the right and one to
the left. The one on the left is populated by a datatable. The user selects
an item(s) in the left and clicks the right arrow to move the item to the
right listbox. Once the items are moved (in each UserControl) the user
clicks a button (on the ASPX) and a Where statement is made of all the
items, in each UserControl.
There are also radiobuttons that sometimes appear above the left listbox so
the user can choose how they want to see the data they want to select. By
either the code or the description.

So when each UserControl is created, I set about three properties to the
UserControl: radio buttons to choose code or description, the DataTable to
be used, the name of the field that the where statement will be queried on.

I thought about the dynamic adding of controls, but I can't figure out how
to do that if each one is loaded by a separate DataTable.

Thank you.

"Sean Chambers" <dk****@gmail.c omwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
Ok,

If changes inside one UserControl only affect that UserControl, then
you should have no event wiring in the aspx page. Keep all of your
event related wiring within the UserControl.

In each UserControl you will have to wire the events for that
UserControl via InitializeCompo nent.

Now, for my next question,
Is each UserControl exactly the same? or all they all different?

Because if they are all the same, you can dynamically add them to the
page which would save you a great deal of time.

Gummy wrote:
>dkode,

Once again, thanks so much for the very detailed reply and link.

It is Scenario 1. Right now when a change is made to the UserControl, I
have
that event in the UserControl and it is wired up in the ASPX.

Specifically , do I need to have every single UserControl wired in the
ASPX
page? In the code below, the rblCodeDescrCha nged is the Event in the
UserControl. So do I need to add the line for each UserControl
(ucLocation,
ucDepartment , etc.)?

private void InitializeCompo nent(){
this.Load += new System.EventHan dler(this.Page_ Load);
ucLocation.rblC odeDescrChanged += new
System.EventHa ndler(this.Chan gedSelectionUCR adioButtons);
ucDepartment.rb lCodeDescrChang ed += new
System.EventHa ndler(this.Chan gedSelectionUCR adioButtons);
}

By the way, the code compiles just fine, but I do get the error saying
that
the rblCodeDescrCha nged event does not exist (or something like that),
when
obviously it does. Any thoughts on that?

What if I have multiple events in the UserControl? One for a button
click,
one for a dropdownlistbox , do I need to wire the user control for each
event. My hope and assumption is that I can use the Delegates for that
(I'll
read the link you sent).

I really appreciate you taking the time to answer my questions so
thoroughly. You have helped me so much and I've learned a great deal.
Thank
you.

-Gummy
"dkode" <dk****@gmail.c omwrote in message
news:11******* *************** @h48g2000cwc.go oglegroups.com. ..
Ok,

That gives me a better idea of what you are trying to do. Next
question:

Is the data that is changed in one UserControl change the data to be
displayed in other UserControls?

Secnario 1:
If you only need to change one UserControls data, then keep you all of
your processing within the UserControls on that level, don't bother
handling anything within the ASPX page, this will only make your
processing more complicated and unnecessary. In this sense, what you
would do is wire up the SelectedIndexCh anged event, and handle it
within the appropraite UserControl

Secnario 2:
If one change on one UserControl changes data on all/other UserControls
on the page, it depends on what type of change is taking place.

If you need to reload/modify only a couple of UserControls it might be
best to have methods in your ASPX page that one UserControl calls and
then it can change other UserControls. If you need to reload ALL the
UserControls you could have a delegate setup in your ASPX page that all
of your usercontrols can subscribe to, then when one change is made,
you could fire the delegate that would in turn call methods on other
usercontrols. (this would be the true OOP approach to your problem,
using a multicast delegate)

Heres a tutorial on multicast delegates:
http://en.csharp-online.net/index.ph...tes_and_Events
Gummy wrote:
dkode,

Thank you for responding..

I think I may have mislead you by having the
ReLoadControls ((Selection)sen der) method. It should be more like
PutInNewDataBa sedOnRadioButto nChoices((Selec tion)sender). So I am not
reloading each UserControl, they are placed statically on the page, I
am
just reloading or changing the data that appears in the specific
UserControl.

Being new to this, I am not exactly sure what the difference is
between
wiring up the Events in the UserControl or on the ASPX page. My
assumption
is that I need to have an event in the UserControl that is raised when
an
RadioButtonLis t is selected. Then that Event can only be recognized in
the
ASPX page if I wire it, for each an every UserControl. To me, it seems
like
there is a better way to do it (not that I have any clue). For
example,
if a
button is clicked on a UserControl, I thought the Event is raised and
the
ASPX page should know that something was clicked on it and then be
able
to
find the specific UserControl that was clicked. All that without
actually
having to manually wire each Event in the ASPX page. Maybe I am taking
OOP
too far?

So if I understand you correctly, I may be doing this right. Right?

The issue, so to speak, was that I was talking to a programmer and he
only
gave hints about ViewStates and other methodologies to be more in line
with
proper OOP. For now, I figure it works and as I learn more I can
improve
upon it.

Thanks again so much for the information.

-Gummy

"dkode" <dk****@gmail.c omwrote in message
news:11******* *************** @h48g2000cwc.go oglegroups.com. ..
Is all you have to do is reload all the UserControls on the aspx
page?

In this case, there is no need to wire up all of these controls on
your
aspx page, you should defer these events into the UserControl
itself.
Otherwise you have to wire up each and every event like you are
doing.

If you wire the events within the UserControl, and have each of them
call a method on the aspx page to "ReloadControls " then that should
do
the trick.

What advantage are you getting out of wiring the events on the aspx
page?

Maybe I'm missing something. Someone correct me if I am wrong
please.

Thanks

Sean

Gummy wrote:
Hello,

I created a user control that has a ListBox and a RadioButtonList
(and
other
stuff). The idea is that I put the user control on the ASPX page
multiple
times and each user control will load with different data
(locations,
departments, etc.).

When I click the RadioButtonList the Event is raised on the user
control
and
I can consume(?) it on the ASPX page. However, I needed to give
each
user
control its own ID, add the "protected UserControlType
userControlI D"
to
the
declarations , and then wire each of them to an Event to get them to
work
or
to even recognize their ID when the Event is raised.

It works, but my understanding that this is a poor way of doing
things.
Is
there a better way to approach this?

Here's some of the code in the ASPX page, to recognize the Event:

private void InitializeCompo nent(){

this.Load += new
System.EventHa ndler(this.Page _Load);

ucLocation.rblC odeDescrChanged
+=
new
System.EventHa ndler(this.Chan gedSelectionUCR adioButtons);

ucDepartment.r blCodeDescrChan ged += new
System.EventHa ndler(this.Chan gedSelectionUCR adioButtons);

}

private void ChangedSelectio nUCRadioButtons (object sender,
System.EventAr gs
e)

{

ReLoadControls ((Selection)sen der);

}

Thank you for the help.

-Gummy


Sep 17 '06 #7
Well,

For beginning, you are on the right track, try not to bite off more
than you can chew.

In the future though, when you get more comfortable, you could easily
do what you are trying to do by dynamically adding the controls. You
would have one UserControl, say BaseControl.asc x, you could then assign
a unique id to the control and add it to a placeholder.

Things get more complex here though, you have to wire the events before
Page_Load, otherwise they will not fire on postback. You have to wire
them in Page_Init. there is also other "gotchas" when working with
dynamically created controls.

Like I said though, your on the right track to begin with, just depends
on how much you want to type and how much hair you want to keep =)

Hope I was helpful!

Sean

Gummy wrote:
I think they are exactly the same - sometimes.
Each one has two listboxes, an ImageButton pointing to the right and one to
the left. The one on the left is populated by a datatable. The user selects
an item(s) in the left and clicks the right arrow to move the item to the
right listbox. Once the items are moved (in each UserControl) the user
clicks a button (on the ASPX) and a Where statement is made of all the
items, in each UserControl.
There are also radiobuttons that sometimes appear above the left listbox so
the user can choose how they want to see the data they want to select. By
either the code or the description.

So when each UserControl is created, I set about three properties to the
UserControl: radio buttons to choose code or description, the DataTable to
be used, the name of the field that the where statement will be queried on.

I thought about the dynamic adding of controls, but I can't figure out how
to do that if each one is loaded by a separate DataTable.

Thank you.

"Sean Chambers" <dk****@gmail.c omwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
Ok,

If changes inside one UserControl only affect that UserControl, then
you should have no event wiring in the aspx page. Keep all of your
event related wiring within the UserControl.

In each UserControl you will have to wire the events for that
UserControl via InitializeCompo nent.

Now, for my next question,
Is each UserControl exactly the same? or all they all different?

Because if they are all the same, you can dynamically add them to the
page which would save you a great deal of time.

Gummy wrote:
dkode,

Once again, thanks so much for the very detailed reply and link.

It is Scenario 1. Right now when a change is made to the UserControl, I
have
that event in the UserControl and it is wired up in the ASPX.

Specifically, do I need to have every single UserControl wired in the
ASPX
page? In the code below, the rblCodeDescrCha nged is the Event in the
UserControl. So do I need to add the line for each UserControl
(ucLocation,
ucDepartment, etc.)?

private void InitializeCompo nent(){
this.Load += new System.EventHan dler(this.Page_ Load);
ucLocation.rblC odeDescrChanged += new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);
ucDepartment.rb lCodeDescrChang ed += new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);
}

By the way, the code compiles just fine, but I do get the error saying
that
the rblCodeDescrCha nged event does not exist (or something like that),
when
obviously it does. Any thoughts on that?

What if I have multiple events in the UserControl? One for a button
click,
one for a dropdownlistbox , do I need to wire the user control for each
event. My hope and assumption is that I can use the Delegates for that
(I'll
read the link you sent).

I really appreciate you taking the time to answer my questions so
thoroughly. You have helped me so much and I've learned a great deal.
Thank
you.

-Gummy
"dkode" <dk****@gmail.c omwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
Ok,

That gives me a better idea of what you are trying to do. Next
question:

Is the data that is changed in one UserControl change the data to be
displayed in other UserControls?

Secnario 1:
If you only need to change one UserControls data, then keep you all of
your processing within the UserControls on that level, don't bother
handling anything within the ASPX page, this will only make your
processing more complicated and unnecessary. In this sense, what you
would do is wire up the SelectedIndexCh anged event, and handle it
within the appropraite UserControl

Secnario 2:
If one change on one UserControl changes data on all/other UserControls
on the page, it depends on what type of change is taking place.

If you need to reload/modify only a couple of UserControls it might be
best to have methods in your ASPX page that one UserControl calls and
then it can change other UserControls. If you need to reload ALL the
UserControls you could have a delegate setup in your ASPX page that all
of your usercontrols can subscribe to, then when one change is made,
you could fire the delegate that would in turn call methods on other
usercontrols. (this would be the true OOP approach to your problem,
using a multicast delegate)

Heres a tutorial on multicast delegates:
http://en.csharp-online.net/index.ph...tes_and_Events
Gummy wrote:
dkode,

Thank you for responding..

I think I may have mislead you by having the
ReLoadControls( (Selection)send er) method. It should be more like
PutInNewDataBas edOnRadioButton Choices((Select ion)sender). So I am not
reloading each UserControl, they are placed statically on the page, I
am
just reloading or changing the data that appears in the specific
UserControl.

Being new to this, I am not exactly sure what the difference is
between
wiring up the Events in the UserControl or on the ASPX page. My
assumption
is that I need to have an event in the UserControl that is raised when
an
RadioButtonList is selected. Then that Event can only be recognized in
the
ASPX page if I wire it, for each an every UserControl. To me, it seems
like
there is a better way to do it (not that I have any clue). For
example,
if a
button is clicked on a UserControl, I thought the Event is raised and
the
ASPX page should know that something was clicked on it and then be
able
to
find the specific UserControl that was clicked. All that without
actually
having to manually wire each Event in the ASPX page. Maybe I am taking
OOP
too far?

So if I understand you correctly, I may be doing this right. Right?

The issue, so to speak, was that I was talking to a programmer and he
only
gave hints about ViewStates and other methodologies to be more in line
with
proper OOP. For now, I figure it works and as I learn more I can
improve
upon it.

Thanks again so much for the information.

-Gummy

"dkode" <dk****@gmail.c omwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
Is all you have to do is reload all the UserControls on the aspx
page?

In this case, there is no need to wire up all of these controls on
your
aspx page, you should defer these events into the UserControl
itself.
Otherwise you have to wire up each and every event like you are
doing.

If you wire the events within the UserControl, and have each of them
call a method on the aspx page to "ReloadControls " then that should
do
the trick.

What advantage are you getting out of wiring the events on the aspx
page?

Maybe I'm missing something. Someone correct me if I am wrong
please.

Thanks

Sean

Gummy wrote:
Hello,

I created a user control that has a ListBox and a RadioButtonList
(and
other
stuff). The idea is that I put the user control on the ASPX page
multiple
times and each user control will load with different data
(locations,
departments, etc.).

When I click the RadioButtonList the Event is raised on the user
control
and
I can consume(?) it on the ASPX page. However, I needed to give
each
user
control its own ID, add the "protected UserControlType
userControlID"
to
the
declarations, and then wire each of them to an Event to get them to
work
or
to even recognize their ID when the Event is raised.

It works, but my understanding that this is a poor way of doing
things.
Is
there a better way to approach this?

Here's some of the code in the ASPX page, to recognize the Event:

private void InitializeCompo nent(){

this.Load += new
System.EventHan dler(this.Page_ Load);

ucLocation.rblC odeDescrChanged
+=
new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);

ucDepartment.rb lCodeDescrChang ed += new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);

}

private void ChangedSelectio nUCRadioButtons (object sender,
System.EventArg s
e)

{

ReLoadControls( (Selection)send er);

}

Thank you for the help.

-Gummy
Sep 18 '06 #8
Sean,

You have been amazingly helpful and I really appreciate all the time you
took to respond to all my questions.

I have been biting off way too much (and I think I am going to be sick).

I have now gone down the path of dynamically loading the controls and I've
just started learning about the Page_Init stuff. And you're right, I am
pulling out lots of hair.

I am in the middle of figuring out how when the dynamic controls are
reloaded not to make that so slow.

Thanks again for all your help.

"Sean Chambers" <dk****@gmail.c omwrote in message
news:11******** *************@i 3g2000cwc.googl egroups.com...
Well,

For beginning, you are on the right track, try not to bite off more
than you can chew.

In the future though, when you get more comfortable, you could easily
do what you are trying to do by dynamically adding the controls. You
would have one UserControl, say BaseControl.asc x, you could then assign
a unique id to the control and add it to a placeholder.

Things get more complex here though, you have to wire the events before
Page_Load, otherwise they will not fire on postback. You have to wire
them in Page_Init. there is also other "gotchas" when working with
dynamically created controls.

Like I said though, your on the right track to begin with, just depends
on how much you want to type and how much hair you want to keep =)

Hope I was helpful!

Sean

Gummy wrote:
>I think they are exactly the same - sometimes.
Each one has two listboxes, an ImageButton pointing to the right and one
to
the left. The one on the left is populated by a datatable. The user
selects
an item(s) in the left and clicks the right arrow to move the item to the
right listbox. Once the items are moved (in each UserControl) the user
clicks a button (on the ASPX) and a Where statement is made of all the
items, in each UserControl.
There are also radiobuttons that sometimes appear above the left listbox
so
the user can choose how they want to see the data they want to select. By
either the code or the description.

So when each UserControl is created, I set about three properties to the
UserControl: radio buttons to choose code or description, the DataTable
to
be used, the name of the field that the where statement will be queried
on.

I thought about the dynamic adding of controls, but I can't figure out
how
to do that if each one is loaded by a separate DataTable.

Thank you.

"Sean Chambers" <dk****@gmail.c omwrote in message
news:11******* *************** @b28g2000cwb.go oglegroups.com. ..
Ok,

If changes inside one UserControl only affect that UserControl, then
you should have no event wiring in the aspx page. Keep all of your
event related wiring within the UserControl.

In each UserControl you will have to wire the events for that
UserControl via InitializeCompo nent.

Now, for my next question,
Is each UserControl exactly the same? or all they all different?

Because if they are all the same, you can dynamically add them to the
page which would save you a great deal of time.

Gummy wrote:
dkode,

Once again, thanks so much for the very detailed reply and link.

It is Scenario 1. Right now when a change is made to the UserControl,
I
have
that event in the UserControl and it is wired up in the ASPX.

Specifically , do I need to have every single UserControl wired in the
ASPX
page? In the code below, the rblCodeDescrCha nged is the Event in the
UserControl. So do I need to add the line for each UserControl
(ucLocation,
ucDepartment , etc.)?

private void InitializeCompo nent(){
this.Load += new System.EventHan dler(this.Page_ Load);
ucLocation.rblC odeDescrChanged += new
System.EventHa ndler(this.Chan gedSelectionUCR adioButtons);
ucDepartment.rb lCodeDescrChang ed += new
System.EventHa ndler(this.Chan gedSelectionUCR adioButtons);
}

By the way, the code compiles just fine, but I do get the error saying
that
the rblCodeDescrCha nged event does not exist (or something like that),
when
obviously it does. Any thoughts on that?

What if I have multiple events in the UserControl? One for a button
click,
one for a dropdownlistbox , do I need to wire the user control for each
event. My hope and assumption is that I can use the Delegates for that
(I'll
read the link you sent).

I really appreciate you taking the time to answer my questions so
thoroughly. You have helped me so much and I've learned a great deal.
Thank
you.

-Gummy
"dkode" <dk****@gmail.c omwrote in message
news:11******* *************** @h48g2000cwc.go oglegroups.com. ..
Ok,

That gives me a better idea of what you are trying to do. Next
question:

Is the data that is changed in one UserControl change the data to be
displayed in other UserControls?

Secnario 1:
If you only need to change one UserControls data, then keep you all
of
your processing within the UserControls on that level, don't bother
handling anything within the ASPX page, this will only make your
processing more complicated and unnecessary. In this sense, what you
would do is wire up the SelectedIndexCh anged event, and handle it
within the appropraite UserControl

Secnario 2:
If one change on one UserControl changes data on all/other
UserControls
on the page, it depends on what type of change is taking place.

If you need to reload/modify only a couple of UserControls it might
be
best to have methods in your ASPX page that one UserControl calls
and
then it can change other UserControls. If you need to reload ALL the
UserControls you could have a delegate setup in your ASPX page that
all
of your usercontrols can subscribe to, then when one change is made,
you could fire the delegate that would in turn call methods on other
usercontrols. (this would be the true OOP approach to your problem,
using a multicast delegate)

Heres a tutorial on multicast delegates:
http://en.csharp-online.net/index.ph...tes_and_Events
Gummy wrote:
dkode,

Thank you for responding..

I think I may have mislead you by having the
ReLoadControls ((Selection)sen der) method. It should be more like
PutInNewDataBa sedOnRadioButto nChoices((Selec tion)sender). So I am
not
reloading each UserControl, they are placed statically on the page,
I
am
just reloading or changing the data that appears in the specific
UserControl.

Being new to this, I am not exactly sure what the difference is
between
wiring up the Events in the UserControl or on the ASPX page. My
assumption
is that I need to have an event in the UserControl that is raised
when
an
RadioButtonLis t is selected. Then that Event can only be recognized
in
the
ASPX page if I wire it, for each an every UserControl. To me, it
seems
like
there is a better way to do it (not that I have any clue). For
example,
if a
button is clicked on a UserControl, I thought the Event is raised
and
the
ASPX page should know that something was clicked on it and then be
able
to
find the specific UserControl that was clicked. All that without
actually
having to manually wire each Event in the ASPX page. Maybe I am
taking
OOP
too far?

So if I understand you correctly, I may be doing this right. Right?

The issue, so to speak, was that I was talking to a programmer and
he
only
gave hints about ViewStates and other methodologies to be more in
line
with
proper OOP. For now, I figure it works and as I learn more I can
improve
upon it.

Thanks again so much for the information.

-Gummy

"dkode" <dk****@gmail.c omwrote in message
news:11******* *************** @h48g2000cwc.go oglegroups.com. ..
Is all you have to do is reload all the UserControls on the aspx
page?

In this case, there is no need to wire up all of these controls
on
your
aspx page, you should defer these events into the UserControl
itself.
Otherwise you have to wire up each and every event like you are
doing.

If you wire the events within the UserControl, and have each of
them
call a method on the aspx page to "ReloadControls " then that
should
do
the trick.

What advantage are you getting out of wiring the events on the
aspx
page?

Maybe I'm missing something. Someone correct me if I am wrong
please.

Thanks

Sean

Gummy wrote:
Hello,

I created a user control that has a ListBox and a
RadioButtonLis t
(and
other
stuff). The idea is that I put the user control on the ASPX page
multiple
times and each user control will load with different data
(locations,
departments, etc.).

When I click the RadioButtonList the Event is raised on the user
control
and
I can consume(?) it on the ASPX page. However, I needed to give
each
user
control its own ID, add the "protected UserControlType
userControlI D"
to
the
declarations , and then wire each of them to an Event to get them
to
work
or
to even recognize their ID when the Event is raised.

It works, but my understanding that this is a poor way of doing
things.
Is
there a better way to approach this?

Here's some of the code in the ASPX page, to recognize the
Event:

private void InitializeCompo nent(){

this.Load += new
System.EventHa ndler(this.Page _Load);
ucLocation.rbl CodeDescrChange d
+=
new
System.EventHa ndler(this.Chan gedSelectionUCR adioButtons);

ucDepartment.r blCodeDescrChan ged += new
System.EventHa ndler(this.Chan gedSelectionUCR adioButtons);

}

private void ChangedSelectio nUCRadioButtons (object sender,
System.EventAr gs
e)

{

ReLoadControls ((Selection)sen der);

}

Thank you for the help.

-Gummy

Sep 19 '06 #9
No problem,

There are quiet a few tutorials on csharp-online.net and
thecodeproject. com as well as msdn.microsoft. com that talk about
dynamically created controls.

That should help you out.

Sean

Gummy wrote:
Sean,

You have been amazingly helpful and I really appreciate all the time you
took to respond to all my questions.

I have been biting off way too much (and I think I am going to be sick).

I have now gone down the path of dynamically loading the controls and I've
just started learning about the Page_Init stuff. And you're right, I am
pulling out lots of hair.

I am in the middle of figuring out how when the dynamic controls are
reloaded not to make that so slow.

Thanks again for all your help.

"Sean Chambers" <dk****@gmail.c omwrote in message
news:11******** *************@i 3g2000cwc.googl egroups.com...
Well,

For beginning, you are on the right track, try not to bite off more
than you can chew.

In the future though, when you get more comfortable, you could easily
do what you are trying to do by dynamically adding the controls. You
would have one UserControl, say BaseControl.asc x, you could then assign
a unique id to the control and add it to a placeholder.

Things get more complex here though, you have to wire the events before
Page_Load, otherwise they will not fire on postback. You have to wire
them in Page_Init. there is also other "gotchas" when working with
dynamically created controls.

Like I said though, your on the right track to begin with, just depends
on how much you want to type and how much hair you want to keep =)

Hope I was helpful!

Sean

Gummy wrote:
I think they are exactly the same - sometimes.
Each one has two listboxes, an ImageButton pointing to the right and one
to
the left. The one on the left is populated by a datatable. The user
selects
an item(s) in the left and clicks the right arrow to move the item to the
right listbox. Once the items are moved (in each UserControl) the user
clicks a button (on the ASPX) and a Where statement is made of all the
items, in each UserControl.
There are also radiobuttons that sometimes appear above the left listbox
so
the user can choose how they want to see the data they want to select. By
either the code or the description.

So when each UserControl is created, I set about three properties to the
UserControl: radio buttons to choose code or description, the DataTable
to
be used, the name of the field that the where statement will be queried
on.

I thought about the dynamic adding of controls, but I can't figure out
how
to do that if each one is loaded by a separate DataTable.

Thank you.

"Sean Chambers" <dk****@gmail.c omwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
Ok,

If changes inside one UserControl only affect that UserControl, then
you should have no event wiring in the aspx page. Keep all of your
event related wiring within the UserControl.

In each UserControl you will have to wire the events for that
UserControl via InitializeCompo nent.

Now, for my next question,
Is each UserControl exactly the same? or all they all different?

Because if they are all the same, you can dynamically add them to the
page which would save you a great deal of time.

Gummy wrote:
dkode,

Once again, thanks so much for the very detailed reply and link.

It is Scenario 1. Right now when a change is made to the UserControl,
I
have
that event in the UserControl and it is wired up in the ASPX.

Specifically, do I need to have every single UserControl wired in the
ASPX
page? In the code below, the rblCodeDescrCha nged is the Event in the
UserControl. So do I need to add the line for each UserControl
(ucLocation,
ucDepartment, etc.)?

private void InitializeCompo nent(){
this.Load += new System.EventHan dler(this.Page_ Load);
ucLocation.rblC odeDescrChanged += new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);
ucDepartment.rb lCodeDescrChang ed += new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);
}

By the way, the code compiles just fine, but I do get the error saying
that
the rblCodeDescrCha nged event does not exist (or something like that),
when
obviously it does. Any thoughts on that?

What if I have multiple events in the UserControl? One for a button
click,
one for a dropdownlistbox , do I need to wire the user control for each
event. My hope and assumption is that I can use the Delegates for that
(I'll
read the link you sent).

I really appreciate you taking the time to answer my questions so
thoroughly. You have helped me so much and I've learned a great deal.
Thank
you.

-Gummy
"dkode" <dk****@gmail.c omwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
Ok,

That gives me a better idea of what you are trying to do. Next
question:

Is the data that is changed in one UserControl change the data to be
displayed in other UserControls?

Secnario 1:
If you only need to change one UserControls data, then keep you all
of
your processing within the UserControls on that level, don't bother
handling anything within the ASPX page, this will only make your
processing more complicated and unnecessary. In this sense, what you
would do is wire up the SelectedIndexCh anged event, and handle it
within the appropraite UserControl

Secnario 2:
If one change on one UserControl changes data on all/other
UserControls
on the page, it depends on what type of change is taking place.

If you need to reload/modify only a couple of UserControls it might
be
best to have methods in your ASPX page that one UserControl calls
and
then it can change other UserControls. If you need to reload ALL the
UserControls you could have a delegate setup in your ASPX page that
all
of your usercontrols can subscribe to, then when one change is made,
you could fire the delegate that would in turn call methods on other
usercontrols. (this would be the true OOP approach to your problem,
using a multicast delegate)

Heres a tutorial on multicast delegates:
http://en.csharp-online.net/index.ph...tes_and_Events
Gummy wrote:
dkode,

Thank you for responding..

I think I may have mislead you by having the
ReLoadControls( (Selection)send er) method. It should be more like
PutInNewDataBas edOnRadioButton Choices((Select ion)sender). So I am
not
reloading each UserControl, they are placed statically on the page,
I
am
just reloading or changing the data that appears in the specific
UserControl.

Being new to this, I am not exactly sure what the difference is
between
wiring up the Events in the UserControl or on the ASPX page. My
assumption
is that I need to have an event in the UserControl that is raised
when
an
RadioButtonList is selected. Then that Event can only be recognized
in
the
ASPX page if I wire it, for each an every UserControl. To me, it
seems
like
there is a better way to do it (not that I have any clue). For
example,
if a
button is clicked on a UserControl, I thought the Event is raised
and
the
ASPX page should know that something was clicked on it and then be
able
to
find the specific UserControl that was clicked. All that without
actually
having to manually wire each Event in the ASPX page. Maybe I am
taking
OOP
too far?

So if I understand you correctly, I may be doing this right. Right?

The issue, so to speak, was that I was talking to a programmer and
he
only
gave hints about ViewStates and other methodologies to be more in
line
with
proper OOP. For now, I figure it works and as I learn more I can
improve
upon it.

Thanks again so much for the information.

-Gummy

"dkode" <dk****@gmail.c omwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
Is all you have to do is reload all the UserControls on the aspx
page?

In this case, there is no need to wire up all of these controls
on
your
aspx page, you should defer these events into the UserControl
itself.
Otherwise you have to wire up each and every event like you are
doing.

If you wire the events within the UserControl, and have each of
them
call a method on the aspx page to "ReloadControls " then that
should
do
the trick.

What advantage are you getting out of wiring the events on the
aspx
page?

Maybe I'm missing something. Someone correct me if I am wrong
please.

Thanks

Sean

Gummy wrote:
Hello,

I created a user control that has a ListBox and a
RadioButtonList
(and
other
stuff). The idea is that I put the user control on the ASPX page
multiple
times and each user control will load with different data
(locations,
departments, etc.).

When I click the RadioButtonList the Event is raised on the user
control
and
I can consume(?) it on the ASPX page. However, I needed to give
each
user
control its own ID, add the "protected UserControlType
userControlID"
to
the
declarations, and then wire each of them to an Event to get them
to
work
or
to even recognize their ID when the Event is raised.

It works, but my understanding that this is a poor way of doing
things.
Is
there a better way to approach this?

Here's some of the code in the ASPX page, to recognize the
Event:

private void InitializeCompo nent(){

this.Load += new
System.EventHan dler(this.Page_ Load);
ucLocation.rblC odeDescrChanged
+=
new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);

ucDepartment.rb lCodeDescrChang ed += new
System.EventHan dler(this.Chang edSelectionUCRa dioButtons);

}

private void ChangedSelectio nUCRadioButtons (object sender,
System.EventArg s
e)

{

ReLoadControls( (Selection)send er);

}

Thank you for the help.

-Gummy

Sep 19 '06 #10

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

Similar topics

13
5069
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
4
40069
by: Rachel Suddeth | last post by:
What is the difference between a managed/unmanaged resource, and how do you tell which is which? I'm trying to understand how to write some Dispose() methods, and we are supposed to put code that deals with managed in one place, and code that deals with unmanaged in another place, but I can't seem to find anything that clearly explains what that means. I think if I used a Windows API function to optain a handle, that handle would be an...
9
2235
by: AFN | last post by:
I was just dropped into someone else's code (isn't that always so fun?). I can't figure out why a custom validation control's server event function is executing. There is nothing (that I see) in page_load, or elsewhere, that says page.validate, no control says "causesvalidation=true", and the AutoEventWireup is set to false. So I would think that the control's server event function would NOT execute, but it does execute right after...
17
8052
by: | last post by:
I have an app that retrieves data from an Access database. At the moment I have the SQL string as a Const in my app. I understand this is not best practice. I don't want the user to have access to read or modify this string so I don't want to store it in an INI / Text file or in registery. Can someone please tell me the best practice for this. Thanks Mike
5
2539
by: BK | last post by:
We've got a fairly large scale development process under way in .NET 2003. We are about a month away from go-live for phase 1, second phase is rather short and all work should be completed in the next 2 months. Looking back on problems encountered, we want to learn from this project. FWIW, we are nearly on time with the original time line (only off by about a month), and we actually added more functionality than the original specs...
669
26390
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
5
5926
by: Rich | last post by:
Hello, I have a search application to search data in tables in a database (3 sql server tables). I populate 2 comboboxes with with data from each table. One combobox will contain unique CompanyID's. The second combobox will contain unique memberID's. Each of the tables that I have to search contain a CompanyID and a memberID field, and these fields are not unique in the respective tables. Like CompanyID, MemberID
2
1408
by: jdp | last post by:
I've created a custom login control with values that are not used in the Membership table. I created these other fields through the <profiletag in the web config. I'm able to get a new member created my calling membership.create user and get the other fields saved by creating an instance of ProfileBase, calling SetPropertyValue("property",value) mulitple times for each property, and finally calling the Save method. My first question is:...
1
2476
by: AndiSmith | last post by:
Hi guys, I wondered if anyone could help me with this problem, or even shed some light on the direction I need to take to resolve it? I'm using .NET 2.0 (C# flavor) to build a large user-based website. I've created an AJAX based user control, which is dynamically placed on a page (once, or multiple times) if the user has the correct permissions to receive it. It contains two drop down lists - employee value and partner value; and a...
0
9918
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9763
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
11060
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...
0
10697
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10786
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10389
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5762
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
5959
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3202
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.