Calling user control methods within user controls

Calling user control methods within user controls

Post by Matt Tapi » Sun, 10 Nov 2002 05:46:21



I have an aspx page called home.aspx that has a user control call
menu.ascx...

within menu.ascx I have a user control call menu_item.ascx.

I can call methods of the menu.ascx control from my home.aspx page and I can
call methods of the menu_item.ascx control from the menu.ascx control.

My question is: How or Can I call methods of the menu_item.ascx page from
the home.aspx page?

 
 
 

Calling user control methods within user controls

Post by Steve C. Orr, MCS » Sun, 10 Nov 2002 05:54:07


Make sure your menu_item control is declared as public in your menu control.
Then you should be able to do what you want with code similar to this:
menu_item.menu.mymethod

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net


Quote:> I have an aspx page called home.aspx that has a user control call
> menu.ascx...

> within menu.ascx I have a user control call menu_item.ascx.

> I can call methods of the menu.ascx control from my home.aspx page and I
can
> call methods of the menu_item.ascx control from the menu.ascx control.

> My question is: How or Can I call methods of the menu_item.ascx page from
> the home.aspx page?


 
 
 

1. web user control within a web user control

Have web user control that contains four buttons and one a user clicks
a button another web user control is posted to the placeholder.  My
question is after the user enters some data into the textbox and
clicks submit, the child web user control goes away( which i
understand as page_load being called for parent web user control ) and
my database code never gets executed.  I load the child web user
controls dynamically, which is rendered from the use selecting a
particular button.  I have seen several responses to this, but nothing
that as provided answer.  I do understand that the child web user
control is no longer load.

Code:

private void Page_Load(object sender, System.EventArgs e)
{
if( Page.IsPostBack )
{
AddNewProject.Enabled = true;
AddNewComponent.Enabled = true;
DeleteComponent.Enabled = true;
RegisterUsers.Enabled = true;

private void DisplayControl( )
{
try
{
this.plcContent.Controls.Add( Page.LoadControl( "~/Administrators/" +
PageName + ".ascx" ) );
this.ShowSelection( PageName );
catch( Exception )
{
this.plcContent.Controls.Add( new System.Web.UI.LiteralControl(
"Invalid Selection!" ) );

private void ShowSelection( string sPage )
{
Button l_Button = (Button)this.FindControl( sPage );
l_Button.Enabled = false;

private void DeleteComponent_Click(object sender, System.EventArgs e)
{
PageName = "DeleteComponent";
DisplayControl( );

private void AddNewComponent_Click(object sender, System.EventArgs e)
{
PageName = "AddNewComponent";        
DisplayControl( );

private void AddNewProject_Click(object sender, System.EventArgs e)
{
PageName = "AddNewProject";
DisplayControl( );

private void RegisterUsers_Click(object sender, System.EventArgs e)
{
PageName = "RegisterUsers";          
DisplayControl( );

2. Hamming distance for trees

3. Data binding DropDownList user control within other user controls

4. Printing problem..

5. Calling an user control from another user control

6. OS/2 for PPC to be licensed by Apple!

7. Custom control vs User control / Sizing controls within custom control

8. How do I do a SET DISPLAY/CREATE programatically?

9. Identifying authenticated users within a user control

10. Overriding user control methods from within a page ?

11. treeview control calling a user control added on a panel control

12. Calling method on User Control's parent form

13. Method Calls and User Controls