.NETGURU
How can I reference a object created by other user control in a web page ?
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngfreeforall' list.


Francisco Devia
Hi all,

I have a web page (aspx) with tree (3) user controls
(Hedear01,ascx,Header02.ascx,body01.ascx), in the codebehind of control
body01.acsx I want to use a dropdownlist that control Header02.acsx
create, but the compiler show me the error :

The type or namespace named my dropdownlist01 could not be found (are
you mi....)

How can I reference a object created by other user control in a web page
?

Thanks in advanced,

Francisco
Reply to this message...
 
    
chris
Page.FindControl("body01ID").FindControl("dropdownlist1");

Assuming the dropdownlist is not nested within anouther control

-Chris Frazier
.NET Solution Developer
Velocity Databank, Inc.
www.velocitydatabank.com

-----Original Message-----
From: Francisco Devia [mailto:Click here to reveal e-mail address]
Sent: Monday, August 12, 2002 5:57 PM
To: aspngfreeforall
Subject: [aspngfreeforall] How can I reference a object created by other
user control in a web page ?

Hi all,

I have a web page (aspx) with tree (3) user controls
(Hedear01,ascx,Header02.ascx,body01.ascx), in the codebehind of control
body01.acsx I want to use a dropdownlist that control Header02.acsx
create, but the compiler show me the error :

The type or namespace named my dropdownlist01 could not be found (are you
mi..)

How can I reference a object created by other user control in a web page ?

Thanks in advanced,

Francisco

| ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/aspngfreeforall = JOIN/QUIT | news://ls.asplists.com
= NEWSGROUP
Reply to this message...
 
    
Francisco Devia
Chris, Thanks

I trayed your code but it does not work to me, maybe can you help me
whit a little more specific code ?.

In header01.acsx is a LinkButton1.
Default.aspx have the controls header01.ascx, Header02.ascx.

In Defaul.aspx.cs I want to access a property of LinkButton1
Something like this ??

Page.FindControl("Header01.acsx").FindControl("dropdownlist1").Text "Hello";

Thanks

Francisco

-----Mensaje original-----
De: chris [mailto:Click here to reveal e-mail address]
Enviado el: Martes, 13 de Agosto de 2002 09:26 a.m.
Para: aspngfreeforall
Asunto: [aspngfreeforall] RE: How can I reference a object created by
other user control in a web page ?

Page.FindControl("body01ID").FindControl("dropdownlist1");

Assuming the dropdownlist is not nested within anouther control

-Chris Frazier
.NET Solution Developer
Velocity Databank, Inc.
www.velocitydatabank.com
    -----Original Message-----
    From: Francisco Devia [mailto:Click here to reveal e-mail address]
    Sent: Monday, August 12, 2002 5:57 PM
    To: aspngfreeforall
    Subject: [aspngfreeforall] How can I reference a object created
by other user control in a web page ?
    Hi all,
    
    I have a web page (aspx) with tree (3) user controls
(Hedear01,ascx,Header02.ascx,body01.ascx), in the codebehind of control
body01.acsx I want to use a dropdownlist that control Header02.acsx
create, but the compiler show me the error :
    
    The type or namespace named my dropdownlist01 could not be found
(are you mi....)
    
    How can I reference a object created by other user control in a
web page ?
    
    Thanks in advanced,
    
    Francisco
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    | ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall]
member Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/aspngfreeforall = JOIN/QUIT |
news://ls.asplists.com = NEWSGROUP
| ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/aspngfreeforall = JOIN/QUIT |
news://ls.asplists.com = NEWSGROUP
Reply to this message...
 
    
chris
Very close, Francisco. If you know that your control heirarchy is set up
this way, then yes, that should work. Just remember that your codebehind
recognizes each element of your webform by ID only, so the control
header01.ascx would be referenced in your code by its ID.

<%@ Register TagPrefix="uc1" TagName="header01" Src="header01.ascx"%>

...

<uc1:header01 id="myHeader" runat="server"></uc1:header01>

...

<codeBehind>
Page.FindControl("myHeader").FindControl("myControl").Text = "It
works!";
</codeBehind>

I used a similar solution to toggle the visibility of a control accessed
from different pages, and that works like a charm.

hth,
-Chris Frazier
.NET Solution Developer
Velocity Databank, Inc.
www.velocitydatabank.com

-----Original Message-----
From: Francisco Devia [mailto:Click here to reveal e-mail address]
Sent: Tuesday, August 13, 2002 12:42 PM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: How can I reference a object created by
other user control in a web page ?

Chris, Thanks

I trayed your code but it does not work to me, maybe can you help me whit
a little more specific code ?.

In header01.acsx is a LinkButton1.

Default.aspx have the controls header01.ascx, Header02.ascx.

In Defaul.aspx.cs I want to access a property of LinkButton1

Something like this ??

Page.FindControl("Header01.acsx").FindControl("dropdownlist1").Text "Hello";

Thanks

Francisco

-----Mensaje original-----
De: chris [mailto:Click here to reveal e-mail address]
Enviado el: Martes, 13 de Agosto de 2002 09:26 a.m.
Para: aspngfreeforall
Asunto: [aspngfreeforall] RE: How can I reference a object created by
other user control in a web page ?

Page.FindControl("body01ID").FindControl("dropdownlist1");

Assuming the dropdownlist is not nested within anouther control

-Chris Frazier
.NET Solution Developer
Velocity Databank, Inc.
www.velocitydatabank.com

-----Original Message-----
From: Francisco Devia [mailto:Click here to reveal e-mail address]
Sent: Monday, August 12, 2002 5:57 PM
To: aspngfreeforall
Subject: [aspngfreeforall] How can I reference a object created by other
user control in a web page ?

Hi all,

I have a web page (aspx) with tree (3) user controls
(Hedear01,ascx,Header02.ascx,body01.ascx), in the codebehind of control
body01.acsx I want to use a dropdownlist that control Header02.acsx
create, but the compiler show me the error :

The type or namespace named my dropdownlist01 could not be found (are
you mi..)

How can I reference a object created by other user control in a web page
?

Thanks in advanced,

Francisco

| ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/aspngfreeforall = JOIN/QUIT | news://ls.asplists.com
= NEWSGROUP

| ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/aspngfreeforall = JOIN/QUIT | news://ls.asplists.com
= NEWSGROUP

| ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/aspngfreeforall = JOIN/QUIT | news://ls.asplists.com
= NEWSGROUP
Reply to this message...
 
    
Mike Simon
RnJhbmNpc2NvLA0KIA0KSXMgdGhlIG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zdHMuY29tID0gTkVXU0dST1VQIDwgL0JMT0NLUVVPVEUgPiANCg=
Reply to this message...
 
    
Francisco Devia
Thanks Mike,

The control is nested inside a ASP table.

Header01.ascx

<table id = "table1">
<tr>
<td>
<asp:LinkButton id="LinkButton1">
</asp:LinkButton>
</td>
</tr>
</table>

The control is not being declared in the top of my .cs file?
How do I do that ?

I Try:

Page.FindControl("Header01.ascx").FindControl("Table1").FindControl("Lin
kButton1").Text = "Hello";

And it did not work.

-----Mensaje original-----
De: Mike Simon [mailto:Click here to reveal e-mail address]
Enviado el: Martes, 13 de Agosto de 2002 01:31 p.m.
Para: aspngfreeforall
Asunto: RE: [aspngfreeforall] RE: How can I reference a object created
by other user control in a web page ?

Francisco,

Is the control nested inside an ASP table?
Is the control being declared in the top of your .cs file?

If it's nested, then you need to know the control hierarchy so that you
can use findcontrols effectively. If not, then if you know that it's
named cmbbox1 then you can reference it directly with
request.form.item("cmbbox1")

If it's not defined in your .cs file at the top, that might be your most
direct approach assuming the above isn't true.

Mike

    -----Original Message-----
    From: Francisco Devia
    Sent: Tue 8/13/2002 12:42 PM
    To: aspngfreeforall
    Cc:
    Subject: [aspngfreeforall] RE: How can I reference a object
created by other user control in a web page ?
    Chris, Thanks
    
    I trayed your code but it does not work to me, maybe can you
help me whit a little more specific code ?.
    
    In header01.acsx is a LinkButton1.
    Default.aspx have the controls header01.ascx, Header02.ascx.
    
    In Defaul.aspx.cs I want to access a property of LinkButton1
    Something like this ??
    

Page.FindControl("Header01.acsx").FindControl("dropdownlist1").Text "Hello";
    
    Thanks
    
    Francisco
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    -----Mensaje original-----
    De: chris [mailto:Click here to reveal e-mail address]
    Enviado el: Martes, 13 de Agosto de 2002 09:26 a.m.
    Para: aspngfreeforall
    Asunto: [aspngfreeforall] RE: How can I reference a object
created by other user control in a web page ?
    
    Page.FindControl("body01ID").FindControl("dropdownlist1");
    
    Assuming the dropdownlist is not nested within anouther control
    
    -Chris Frazier
     .NET Solution Developer
     Velocity Databank, Inc.
     www.velocitydatabank.com
        -----Original Message-----
        From: Francisco Devia
[mailto:Click here to reveal e-mail address]
        Sent: Monday, August 12, 2002 5:57 PM
        To: aspngfreeforall
        Subject: [aspngfreeforall] How can I reference a object
created by other user control in a web page ?
        Hi all,
        
        I have a web page (aspx) with tree (3) user controls
(Hedear01,ascx,Header02.ascx,body01.ascx), in the codebehind of control
body01.acsx I want to use a dropdownlist that control Header02.acsx
create, but the compiler show me the error :
        
        The type or namespace named my dropdownlist01 could not
be found (are you mi....)
        
        How can I reference a object created by other user
control in a web page ?
        
        Thanks in advanced,
        
        Francisco
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        | ASP.net DOCS = http://www.aspng.com/docs |
[aspngfreeforall] member Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/aspngfreeforall = JOIN/QUIT |
news://ls.asplists.com = NEWSGROUP
    | ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall]
member Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/aspngfreeforall = JOIN/QUIT |
news://ls.asplists.com = NEWSGROUP
    | ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall]
member Click here to reveal e-mail address = YOUR ID |
http://www.asplists.com/aspngfreeforall = JOIN/QUIT |
news://ls.asplists.com = NEWSGROUP < /BLOCKQUOTE >
Reply to this message...
 
    
Tim Heuer
Your FindControl("Table1") won't work because you are not declaring
Table1 as a server control.

Did you try
Page.FindControl("Header01.ascx").FindControl("LinkButton1").Text =3D
"Hello";

______________________
Tim Heuer=20

-----Original Message-----
From: Francisco Devia [mailto:Click here to reveal e-mail address]=20
Sent: Tuesday, August 13, 2002 1:23 PM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: How can I reference a object created by
other user control in a web page ?

Thanks Mike,
=20
The control is nested inside a ASP table.
=20
Header01.ascx
=20
<table id =3D "table1">
<tr>
<td>
<asp:LinkButton id=3D"LinkButton1">
</asp:LinkButton>
</td>
</tr>
</table>
=20
The control is not being declared in the top of my .cs file?
How do I do that ?
=20
I Try:
=20
Page.FindControl("Header01.ascx").FindControl("Table1").FindControl("Lin
kButton1").Text =3D "Hello";
=20
And it did not work.
=20
=20
=20
=20
=20
=20
=20
=20
=20
-----Mensaje original-----
De: Mike Simon [mailto:Click here to reveal e-mail address]=20
Enviado el: Martes, 13 de Agosto de 2002 01:31 p.m.
Para: aspngfreeforall
Asunto: RE: [aspngfreeforall] RE: How can I reference a object created
by other user control in a web page ?
=20
Francisco,
=20
Is the control nested inside an ASP table?
Is the control being declared in the top of your .cs file?
=20
If it's nested, then you need to know the control hierarchy so that you
can use findcontrols effectively. If not, then if you know that it's
named cmbbox1 then you can reference it directly with
request.form.item("cmbbox1")
=20
If it's not defined in your .cs file at the top, that might be your most
direct approach assuming the above isn't true.
=20
Mike
=20
=20
=20
-----Original Message-----=20
From: Francisco Devia=20
Sent: Tue 8/13/2002 12:42 PM=20
To: aspngfreeforall=20
Cc:=20
Subject: [aspngfreeforall] RE: How can I reference a object created by
other user control in a web page ?
Chris, Thanks
=20
I trayed your code but it does not work to me, maybe can you help me
whit a little more specific code ?.
=20
In header01.acsx is a LinkButton1.
Default.aspx have the controls header01.ascx, Header02.ascx.
=20
In Defaul.aspx.cs I want to access a property of LinkButton1
Something like this ??
=20
Page.FindControl("Header01.acsx").FindControl("dropdownlist1").Text =3D
"Hello";
=20
Thanks=20
=20
Francisco
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
-----Mensaje original-----
De: chris [mailto:Click here to reveal e-mail address]=20
Enviado el: Martes, 13 de Agosto de 2002 09:26 a.m.
Para: aspngfreeforall
Asunto: [aspngfreeforall] RE: How can I reference a object created by
other user control in a web page ?
=20
Page.FindControl("body01ID").FindControl("dropdownlist1");
=20
Assuming the dropdownlist is not nested within anouther control
=20
-Chris Frazier
.NET Solution Developer
Velocity Databank, Inc.
www.velocitydatabank.com=20
-----Original Message-----
From: Francisco Devia [mailto:Click here to reveal e-mail address]
Sent: Monday, August 12, 2002 5:57 PM
To: aspngfreeforall
Subject: [aspngfreeforall] How can I reference a object created by other
user control in a web page ?
Hi all,
=20
I have a web page (aspx) with tree (3) user controls
(Hedear01,ascx,Header02.ascx,body01.ascx), in the codebehind of control
body01.acsx I want to use a dropdownlist that control Header02.acsx
create, but the compiler show me the error :
=20
The type or namespace named my dropdownlist01 could not be found (are
you mi....)
=20
How can I reference a object created by other user control in a web page
?
=20
Thanks in advanced,
=20
Francisco
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
| ASP.net DOCS =3D http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address =3D YOUR ID |
http://www.asplists.com/aspngfreeforall =3D JOIN/QUIT |
news://ls.asplists.com =3D NEWSGROUP=20
| ASP.net DOCS =3D http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address =3D YOUR ID |
http://www.asplists.com/aspngfreeforall =3D JOIN/QUIT |
news://ls.asplists.com =3D NEWSGROUP=20
| ASP.net DOCS =3D http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address =3D YOUR ID | =
http://www.asplists.com/aspngfreeforall
=3D JOIN/QUIT | news://ls.asplists.com =3D NEWSGROUP < /BLOCKQUOTE >=20
| ASP.net DOCS =3D http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address =3D YOUR ID | http://www.asplists.com/aspngfreeforall =
=3D
JOIN/QUIT | news://ls.asplists.com =3D NEWSGROUP=20

Reply to this message...
 
    
Francisco Devia
Yes tim i did,

And the compiler show the next error:

System.Web.UI.Control does not contain a definition for "Text"

-----Mensaje original-----
De: Tim Heuer [mailto:Click here to reveal e-mail address]=20
Enviado el: Martes, 13 de Agosto de 2002 03:30 p.m.
Para: aspngfreeforall
Asunto: [aspngfreeforall] RE: How can I reference a object created by
other user control in a web page ?

Your FindControl("Table1") won't work because you are not declaring
Table1 as a server control.

Did you try
Page.FindControl("Header01.ascx").FindControl("LinkButton1").Text =3D
"Hello";

______________________
Tim Heuer=20

-----Original Message-----
From: Francisco Devia [mailto:Click here to reveal e-mail address]=20
Sent: Tuesday, August 13, 2002 1:23 PM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: How can I reference a object created by
other user control in a web page ?

Thanks Mike,
=20
The control is nested inside a ASP table.
=20
Header01.ascx
=20
<table id =3D "table1">
<tr>
<td>
<asp:LinkButton id=3D"LinkButton1">
</asp:LinkButton>
</td>
</tr>
</table>
=20
The control is not being declared in the top of my .cs file?
How do I do that ?
=20
I Try:
=20
Page.FindControl("Header01.ascx").FindControl("Table1").FindControl("Lin
kButton1").Text =3D "Hello";
=20
And it did not work.
=20
=20
=20
=20
=20
=20
=20
=20
=20
-----Mensaje original-----
De: Mike Simon [mailto:Click here to reveal e-mail address]=20
Enviado el: Martes, 13 de Agosto de 2002 01:31 p.m.
Para: aspngfreeforall
Asunto: RE: [aspngfreeforall] RE: How can I reference a object created
by other user control in a web page ?
=20
Francisco,
=20
Is the control nested inside an ASP table?
Is the control being declared in the top of your .cs file?
=20
If it's nested, then you need to know the control hierarchy so that you
can use findcontrols effectively. If not, then if you know that it's
named cmbbox1 then you can reference it directly with
request.form.item("cmbbox1")
=20
If it's not defined in your .cs file at the top, that might be your most
direct approach assuming the above isn't true.
=20
Mike
=20
=20
=20
-----Original Message-----=20
From: Francisco Devia=20
Sent: Tue 8/13/2002 12:42 PM=20
To: aspngfreeforall=20
Cc:=20
Subject: [aspngfreeforall] RE: How can I reference a object created by
other user control in a web page ?
Chris, Thanks
=20
I trayed your code but it does not work to me, maybe can you help me
whit a little more specific code ?.
=20
In header01.acsx is a LinkButton1.
Default.aspx have the controls header01.ascx, Header02.ascx.
=20
In Defaul.aspx.cs I want to access a property of LinkButton1
Something like this ??
=20
Page.FindControl("Header01.acsx").FindControl("dropdownlist1").Text =3D
"Hello";
=20
Thanks=20
=20
Francisco
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
-----Mensaje original-----
De: chris [mailto:Click here to reveal e-mail address]=20
Enviado el: Martes, 13 de Agosto de 2002 09:26 a.m.
Para: aspngfreeforall
Asunto: [aspngfreeforall] RE: How can I reference a object created by
other user control in a web page ?
=20
Page.FindControl("body01ID").FindControl("dropdownlist1");
=20
Assuming the dropdownlist is not nested within anouther control
=20
-Chris Frazier
.NET Solution Developer
Velocity Databank, Inc.
www.velocitydatabank.com=20
-----Original Message-----
From: Francisco Devia [mailto:Click here to reveal e-mail address]
Sent: Monday, August 12, 2002 5:57 PM
To: aspngfreeforall
Subject: [aspngfreeforall] How can I reference a object created by other
user control in a web page ?
Hi all,
=20
I have a web page (aspx) with tree (3) user controls
(Hedear01,ascx,Header02.ascx,body01.ascx), in the codebehind of control
body01.acsx I want to use a dropdownlist that control Header02.acsx
create, but the compiler show me the error :
=20
The type or namespace named my dropdownlist01 could not be found (are
you mi....)
=20
How can I reference a object created by other user control in a web page
?
=20
Thanks in advanced,
=20
Francisco
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
| ASP.net DOCS =3D http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address =3D YOUR ID |
http://www.asplists.com/aspngfreeforall =3D JOIN/QUIT |
news://ls.asplists.com =3D NEWSGROUP=20
| ASP.net DOCS =3D http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address =3D YOUR ID |
http://www.asplists.com/aspngfreeforall =3D JOIN/QUIT |
news://ls.asplists.com =3D NEWSGROUP=20
| ASP.net DOCS =3D http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address =3D YOUR ID | =
http://www.asplists.com/aspngfreeforall
=3D JOIN/QUIT | news://ls.asplists.com =3D NEWSGROUP < /BLOCKQUOTE >=20
| ASP.net DOCS =3D http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address =3D YOUR ID | http://www.asplists.com/aspngfreeforall =
=3D
JOIN/QUIT | news://ls.asplists.com =3D NEWSGROUP=20

| ASP.net DOCS =3D http://www.aspng.com/docs
| [aspngfreeforall] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/aspngfreeforall =3D JOIN/QUIT
| news://ls.asplists.com =3D NEWSGROUP

Reply to this message...
 
    
Dot Net Guruhew Tamm
Just to add, FindControl returns a type "Control" which, IIRC, doesn't have
a Text property...cast it to the type you are wanting...

LinkButton myLinkButton =
(LinkButton)Page.FindControl("Header01.ascx").FindControl("LinkButton1");
if ( myLinkButton != null ) myLinkButton.Text = "Hello";

hth

Dot Net Guru.

----- Original Message -----
From: "Tim Heuer" <Click here to reveal e-mail address>
To: "aspngfreeforall" <Click here to reveal e-mail address>
Sent: Tuesday, August 13, 2002 3:30 PM
Subject: [aspngfreeforall] RE: How can I reference a object created by other
user control in a web page ?

Your FindControl("Table1") won't work because you are not declaring
Table1 as a server control.

Did you try
Page.FindControl("Header01.ascx").FindControl("LinkButton1").Text =
"Hello";

______________________
Tim Heuer

-----Original Message-----
From: Francisco Devia [mailto:Click here to reveal e-mail address]
Sent: Tuesday, August 13, 2002 1:23 PM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: How can I reference a object created by
other user control in a web page ?

Thanks Mike,

The control is nested inside a ASP table.

Header01.ascx

<table id = "table1">
<tr>
<td>
<asp:LinkButton id="LinkButton1">
</asp:LinkButton>
</td>
</tr>
</table>

The control is not being declared in the top of my .cs file?
How do I do that ?

I Try:

Page.FindControl("Header01.ascx").FindControl("Table1").FindControl("Lin
kButton1").Text = "Hello";

And it did not work.

-----Mensaje original-----
De: Mike Simon [mailto:Click here to reveal e-mail address]
Enviado el: Martes, 13 de Agosto de 2002 01:31 p.m.
Para: aspngfreeforall
Asunto: RE: [aspngfreeforall] RE: How can I reference a object created
by other user control in a web page ?

Francisco,

Is the control nested inside an ASP table?
Is the control being declared in the top of your .cs file?

If it's nested, then you need to know the control hierarchy so that you
can use findcontrols effectively. If not, then if you know that it's
named cmbbox1 then you can reference it directly with
request.form.item("cmbbox1")

If it's not defined in your .cs file at the top, that might be your most
direct approach assuming the above isn't true.

Mike

Reply to this message...
 
    
Francisco Devia
Thanks Kevin
I Try
((TextBox)Page.FindControl("Header01.ascx").FindControl("LinkButton1")).
Text =3D "Hello";
and
((LinkButton)Page.FindControl("Header01.ascx").FindControl("LinkButton1"
)).Text =3D "Hello";

And in the execution show the error:

Object reference not set to an instance of an object

-----Mensaje original-----
De: Click here to reveal e-mail address [mailto:Click here to reveal e-mail address]=20
Enviado el: Martes, 13 de Agosto de 2002 03:42 p.m.
Para: aspngfreeforall
Asunto: [aspngfreeforall] RE: How can I reference a object created by
other user control in a web page ?

Try
((TextBox)Page.FindControl("Header01.ascx").FindControl("LinkButton1")).
Text

Kevin A. Halleran
-----Original Message-----
From: Francisco Devia [mailto:Click here to reveal e-mail address]=20
Sent: Tuesday, August 13, 2002 4:38 PM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: How can I reference a object created by
other
user control in a web page ?

Yes tim i did,

And the compiler show the next error:

System.Web.UI.Control does not contain a definition for "Text"

-----Mensaje original-----
De: Tim Heuer [mailto:Click here to reveal e-mail address]=20
Enviado el: Martes, 13 de Agosto de 2002 03:30 p.m.
Para: aspngfreeforall
Asunto: [aspngfreeforall] RE: How can I reference a object created by
other user control in a web page ?

Your FindControl("Table1") won't work because you are not declaring
Table1 as a server control.

Did you try
Page.FindControl("Header01.ascx").FindControl("LinkButton1").Text =3D
"Hello";

______________________
Tim Heuer=20

-----Original Message-----
From: Francisco Devia [mailto:Click here to reveal e-mail address]=20
Sent: Tuesday, August 13, 2002 1:23 PM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: How can I reference a object created by
other user control in a web page ?

Thanks Mike,
=20
The control is nested inside a ASP table.
=20
Header01.ascx
=20
<table id =3D "table1">
<tr>
<td>
<asp:LinkButton id=3D"LinkButton1">
</asp:LinkButton>
</td>
</tr>
</table>
=20
The control is not being declared in the top of my .cs file?
How do I do that ?
=20
I Try:
=20
Page.FindControl("Header01.ascx").FindControl("Table1").FindControl("Lin
kButton1").Text =3D "Hello";
=20
And it did not work.
=20
=20
=20
=20
=20
=20
=20
=20
=20
-----Mensaje original-----
De: Mike Simon [mailto:Click here to reveal e-mail address]=20
Enviado el: Martes, 13 de Agosto de 2002 01:31 p.m.
Para: aspngfreeforall
Asunto: RE: [aspngfreeforall] RE: How can I reference a object created
by other user control in a web page ?
=20
Francisco,
=20
Is the control nested inside an ASP table?
Is the control being declared in the top of your .cs file?
=20
If it's nested, then you need to know the control hierarchy so that you
can use findcontrols effectively. If not, then if you know that it's
named cmbbox1 then you can reference it directly with
request.form.item("cmbbox1")
=20
If it's not defined in your .cs file at the top, that might be your most
direct approach assuming the above isn't true.
=20
Mike
=20
=20
=20
-----Original Message-----=20
From: Francisco Devia=20
Sent: Tue 8/13/2002 12:42 PM=20
To: aspngfreeforall=20
Cc:=20
Subject: [aspngfreeforall] RE: How can I reference a object created by
other user control in a web page ?
Chris, Thanks
=20
I trayed your code but it does not work to me, maybe can you help me
whit a little more specific code ?.
=20
In header01.acsx is a LinkButton1.
Default.aspx have the controls header01.ascx, Header02.ascx.
=20
In Defaul.aspx.cs I want to access a property of LinkButton1
Something like this ??
=20
Page.FindControl("Header01.acsx").FindControl("dropdownlist1").Text =3D
"Hello";
=20
Thanks=20
=20
Francisco
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
-----Mensaje original-----
De: chris [mailto:Click here to reveal e-mail address]=20
Enviado el: Martes, 13 de Agosto de 2002 09:26 a.m.
Para: aspngfreeforall
Asunto: [aspngfreeforall] RE: How can I reference a object created by
other user control in a web page ?
=20
Page.FindControl("body01ID").FindControl("dropdownlist1");
=20
Assuming the dropdownlist is not nested within anouther control
=20
-Chris Frazier
.NET Solution Developer
Velocity Databank, Inc.
www.velocitydatabank.com=20
-----Original Message-----
From: Francisco Devia [mailto:Click here to reveal e-mail address]
Sent: Monday, August 12, 2002 5:57 PM
To: aspngfreeforall
Subject: [aspngfreeforall] How can I reference a object created by other
user control in a web page ?
Hi all,
=20
I have a web page (aspx) with tree (3) user controls
(Hedear01,ascx,Header02.ascx,body01.ascx), in the codebehind of control
body01.acsx I want to use a dropdownlist that control Header02.acsx
create, but the compiler show me the error :
=20
The type or namespace named my dropdownlist01 could not be found (are
you mi....)
=20
How can I reference a object created by other user control in a web page
?
=20
Thanks in advanced,
=20
Francisco
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
| ASP.net DOCS =3D http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address =3D YOUR ID |
http://www.asplists.com/aspngfreeforall =3D JOIN/QUIT |
news://ls.asplists.com =3D NEWSGROUP=20
| ASP.net DOCS =3D http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address =3D YOUR ID |
http://www.asplists.com/aspngfreeforall =3D JOIN/QUIT |
news://ls.asplists.com =3D NEWSGROUP=20
| ASP.net DOCS =3D http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address =3D YOUR ID | =
http://www.asplists.com/aspngfreeforall
=3D JOIN/QUIT | news://ls.asplists.com =3D NEWSGROUP < /BLOCKQUOTE >=20
| ASP.net DOCS =3D http://www.aspng.com/docs | [aspngfreeforall] member
Click here to reveal e-mail address =3D YOUR ID | http://www.asplists.com/aspngfreeforall =
=3D
JOIN/QUIT | news://ls.asplists.com =3D NEWSGROUP=20

| ASP.net DOCS =3D http://www.aspng.com/docs
| [aspngfreeforall] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/aspngfreeforall =3D JOIN/QUIT
| news://ls.asplists.com =3D NEWSGROUP

| ASP.net DOCS =3D http://www.aspng.com/docs
| [aspngfreeforall] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/aspngfreeforall =3D JOIN/QUIT
| news://ls.asplists.com =3D NEWSGROUP

| ASP.net DOCS =3D http://www.aspng.com/docs
| [aspngfreeforall] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/aspngfreeforall =3D JOIN/QUIT
| news://ls.asplists.com =3D NEWSGROUP

Reply to this message...
 
 
System.Web.UI.Control
System.Web.UI.MobileControls.TextBox
System.Web.UI.Page
System.Web.UI.WebControls.LinkButton
System.Web.UI.WebControls.TextBox
System.Windows.Forms.TextBox




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification