Obtaining UserControl Name

C

crjunk

On my web form, I have inserted a UserControl, named ReceivedRecord in
two different places on the form. The first UserControl on the web
form is named ReceivedRecord1. It will record records that are
classified as "New". The second user control on the web form is named
ReceivedRecord2 it will record records that are classified as
"Expanded".

When the user clicks on the SAVE button that is on the UserControl, I
want to be able to determine which UserControl, located on my main web
form, the action took place. I've got all my save code on the
CodeBehind page of the UserControl.

Here is what I basically want to be albe to do:

If "user clicks on button from ReceivedRecord1 from main web form"
then
Row.Item("TYPERECORD") = "NEW"
elseif "user Clicks on button from ReceivedRecord2 from main web form"
then
Row.Item("TYPERECORD") = "EXPANDED"
end if

Thanks!
crjunk
 
K

Ken Cox [Microsoft MVP]

Hello ????,

You can get the parent user control of an object using MyBase, so MyBase.ID
should return what you need. For example, try this inside your user control
where lblNotice is on the main .aspx page:

Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
Dim lblNotice As Label
lblNotice = Page.FindControl("label1")
lblNotice.Text = MyBase.ID
End Sub

Does this help?

Ken
Microsoft MVP [ASP.NET]
Toronto
 
C

crjunk

Thanks Ken! That's exaclty what I needed.

Crjunk

Ken Cox said:
Hello ????,

You can get the parent user control of an object using MyBase, so MyBase.ID
should return what you need. For example, try this inside your user control
where lblNotice is on the main .aspx page:

Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
Dim lblNotice As Label
lblNotice = Page.FindControl("label1")
lblNotice.Text = MyBase.ID
End Sub

Does this help?

Ken
Microsoft MVP [ASP.NET]
Toronto

crjunk said:
On my web form, I have inserted a UserControl, named ReceivedRecord in
two different places on the form. The first UserControl on the web
form is named ReceivedRecord1. It will record records that are
classified as "New". The second user control on the web form is named
ReceivedRecord2 it will record records that are classified as
"Expanded".

When the user clicks on the SAVE button that is on the UserControl, I
want to be able to determine which UserControl, located on my main web
form, the action took place. I've got all my save code on the
CodeBehind page of the UserControl.

Here is what I basically want to be albe to do:

If "user clicks on button from ReceivedRecord1 from main web form"
then
Row.Item("TYPERECORD") = "NEW"
elseif "user Clicks on button from ReceivedRecord2 from main web form"
then
Row.Item("TYPERECORD") = "EXPANDED"
end if

Thanks!
crjunk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top