473,406 Members | 2,336 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,406 software developers and data experts.

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 InitializeComponent(){

this.Load += new
System.EventHandler(this.Page_Load);

ucLocation.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);

ucDepartment.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);

}

private void ChangedSelectionUCRadioButtons(object sender, System.EventArgs
e)

{

ReLoadControls((Selection)sender);

}

Thank you for the help.

-Gummy

Sep 13 '06 #1
9 3158
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 InitializeComponent(){

this.Load += new
System.EventHandler(this.Page_Load);

ucLocation.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);

ucDepartment.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);

}

private void ChangedSelectionUCRadioButtons(object sender, System.EventArgs
e)

{

ReLoadControls((Selection)sender);

}

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)sender) method. It should be more like
PutInNewDataBasedOnRadioButtonChoices((Selection)s ender). 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.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.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 InitializeComponent(){

this.Load += new
System.EventHandler(this.Page_Load);

ucLocation.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioB uttons);

ucDepartment.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioB uttons);

}

private void ChangedSelectionUCRadioButtons(object sender,
System.EventArgs
e)

{

ReLoadControls((Selection)sender);

}

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 SelectedIndexChanged 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)sender) method. It should be more like
PutInNewDataBasedOnRadioButtonChoices((Selection)s ender). 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.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.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 InitializeComponent(){

this.Load += new
System.EventHandler(this.Page_Load);

ucLocation.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);

ucDepartment.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);

}

private void ChangedSelectionUCRadioButtons(object sender,
System.EventArgs
e)

{

ReLoadControls((Selection)sender);

}

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 rblCodeDescrChanged is the Event in the
UserControl. So do I need to add the line for each UserControl (ucLocation,
ucDepartment, etc.)?

private void InitializeComponent(){
this.Load += new System.EventHandler(this.Page_Load);
ucLocation.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);
ucDepartment.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);
}

By the way, the code compiles just fine, but I do get the error saying that
the rblCodeDescrChanged 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.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.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 SelectedIndexChanged 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)sender) method. It should be more like
PutInNewDataBasedOnRadioButtonChoices((Selection) 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.comwrote in message
news:11**********************@h48g2000cwc.googleg roups.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 InitializeComponent(){

this.Load += new
System.EventHandler(this.Page_Load);

ucLocation.rblCodeDescrChanged +=
new
System.EventHandler(this.ChangedSelectionUCRadioB uttons);

ucDepartment.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioB uttons);

}

private void ChangedSelectionUCRadioButtons(object sender,
System.EventArgs
e)

{

ReLoadControls((Selection)sender);

}

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 InitializeComponent.

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 rblCodeDescrChanged is the Event in the
UserControl. So do I need to add the line for each UserControl (ucLocation,
ucDepartment, etc.)?

private void InitializeComponent(){
this.Load += new System.EventHandler(this.Page_Load);
ucLocation.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);
ucDepartment.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);
}

By the way, the code compiles just fine, but I do get the error saying that
the rblCodeDescrChanged 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.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.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 SelectedIndexChanged 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)sender) method. It should be more like
PutInNewDataBasedOnRadioButtonChoices((Selection)s ender). 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.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.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 InitializeComponent(){

this.Load += new
System.EventHandler(this.Page_Load);

ucLocation.rblCodeDescrChanged +=
new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);

ucDepartment.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);

}

private void ChangedSelectionUCRadioButtons(object sender,
System.EventArgs
e)

{

ReLoadControls((Selection)sender);

}

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.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.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 InitializeComponent.

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 rblCodeDescrChanged is the Event in the
UserControl. So do I need to add the line for each UserControl
(ucLocation,
ucDepartment, etc.)?

private void InitializeComponent(){
this.Load += new System.EventHandler(this.Page_Load);
ucLocation.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioB uttons);
ucDepartment.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioB uttons);
}

By the way, the code compiles just fine, but I do get the error saying
that
the rblCodeDescrChanged 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.comwrote in message
news:11**********************@h48g2000cwc.googleg roups.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 SelectedIndexChanged 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)sender) method. It should be more like
PutInNewDataBasedOnRadioButtonChoices((Selection) 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.comwrote in message
news:11**********************@h48g2000cwc.googleg roups.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 InitializeComponent(){

this.Load += new
System.EventHandler(this.Page_Load);

ucLocation.rblCodeDescrChanged
+=
new
System.EventHandler(this.ChangedSelectionUCRadioB uttons);

ucDepartment.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioB uttons);

}

private void ChangedSelectionUCRadioButtons(object sender,
System.EventArgs
e)

{

ReLoadControls((Selection)sender);

}

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.ascx, 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.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.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 InitializeComponent.

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 rblCodeDescrChanged is the Event in the
UserControl. So do I need to add the line for each UserControl
(ucLocation,
ucDepartment, etc.)?

private void InitializeComponent(){
this.Load += new System.EventHandler(this.Page_Load);
ucLocation.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);
ucDepartment.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);
}

By the way, the code compiles just fine, but I do get the error saying
that
the rblCodeDescrChanged 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.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.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 SelectedIndexChanged 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)sender) method. It should be more like
PutInNewDataBasedOnRadioButtonChoices((Selection)s ender). 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.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.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 InitializeComponent(){

this.Load += new
System.EventHandler(this.Page_Load);

ucLocation.rblCodeDescrChanged
+=
new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);

ucDepartment.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);

}

private void ChangedSelectionUCRadioButtons(object sender,
System.EventArgs
e)

{

ReLoadControls((Selection)sender);

}

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.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.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.ascx, 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.comwrote in message
news:11**********************@b28g2000cwb.googleg roups.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 InitializeComponent.

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 rblCodeDescrChanged is the Event in the
UserControl. So do I need to add the line for each UserControl
(ucLocation,
ucDepartment, etc.)?

private void InitializeComponent(){
this.Load += new System.EventHandler(this.Page_Load);
ucLocation.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioB uttons);
ucDepartment.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioB uttons);
}

By the way, the code compiles just fine, but I do get the error saying
that
the rblCodeDescrChanged 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.comwrote in message
news:11**********************@h48g2000cwc.googleg roups.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 SelectedIndexChanged 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)sender) method. It should be more like
PutInNewDataBasedOnRadioButtonChoices((Selection) 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.comwrote in message
news:11**********************@h48g2000cwc.googleg roups.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 InitializeComponent(){

this.Load += new
System.EventHandler(this.Page_Load);
ucLocation.rblCodeDescrChanged
+=
new
System.EventHandler(this.ChangedSelectionUCRadioB uttons);

ucDepartment.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioB uttons);

}

private void ChangedSelectionUCRadioButtons(object sender,
System.EventArgs
e)

{

ReLoadControls((Selection)sender);

}

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.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.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.ascx, 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.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.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 InitializeComponent.

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 rblCodeDescrChanged is the Event in the
UserControl. So do I need to add the line for each UserControl
(ucLocation,
ucDepartment, etc.)?

private void InitializeComponent(){
this.Load += new System.EventHandler(this.Page_Load);
ucLocation.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);
ucDepartment.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);
}

By the way, the code compiles just fine, but I do get the error saying
that
the rblCodeDescrChanged 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.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.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 SelectedIndexChanged 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)sender) method. It should be more like
PutInNewDataBasedOnRadioButtonChoices((Selection)s ender). 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.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.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 InitializeComponent(){

this.Load += new
System.EventHandler(this.Page_Load);
ucLocation.rblCodeDescrChanged
+=
new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);

ucDepartment.rblCodeDescrChanged += new
System.EventHandler(this.ChangedSelectionUCRadioBu ttons);

}

private void ChangedSelectionUCRadioButtons(object sender,
System.EventArgs
e)

{

ReLoadControls((Selection)sender);

}

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
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
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...
9
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)...
17
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...
5
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...
669
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...
5
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...
2
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

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.