HighTechTalks DotNet Forums  

ASP.NET UserControl Question

Dotnet Framework microsoft.public.dotnet.framework


Discuss ASP.NET UserControl Question in the Dotnet Framework forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
EdisonCPP
 
Posts: n/a

Default ASP.NET UserControl Question - 10-12-2007 , 09:13 PM






How can I call a function in one UserControl from another?
I have a custom sign in UserControl and another that needs
to display custom information based on the sign in along
the margin. I've been trying things I've found online, but
can't get a definition of the class.

// C#
private void Successful_SignIn()
{
//compile error: OtherControl is not defined
OtherControl control = (OtherControl)Page.FindControl("OtherControl1");
control.ShowCustomInformation();
}

These controls are on a MasterPage.
I have Session variables being setup in the sign in control, but apparently
the 2nd control's Page_Load() is going off before the sign in control.


Thanks,

Steven

Reply With Quote
  #2  
Old   
EdisonCPP
 
Posts: n/a

Default Re: ASP.NET UserControl Question - 10-13-2007 , 05:17 PM






Okay, I was able to get it to compile this line:

OtherControl control = (OtherControl)Page.FindControl("OtherControl1");

by adding:

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

to the top of my aspx page, but now it doesn't know that the function
belongs to the control:

control.ShowCustomInformation();
//says 'OtherControl' does not contain a definition for
'ShowCustomInformation'

Thanks,
Steven



Quote:
How can I call a function in one UserControl from another?
I have a custom sign in UserControl and another that needs
to display custom information based on the sign in along
the margin. I've been trying things I've found online, but
can't get a definition of the class.

// C#
private void Successful_SignIn()
{
//compile error: OtherControl is not defined
OtherControl control = (OtherControl)Page.FindControl("OtherControl1");
control.ShowCustomInformation();
}

These controls are on a MasterPage.
I have Session variables being setup in the sign in control, but
apparently
the 2nd control's Page_Load() is going off before the sign in control.


Thanks,

Steven


Reply With Quote
  #3  
Old   
EdisonCPP
 
Posts: n/a

Default Re: ASP.NET UserControl Question - 10-13-2007 , 05:39 PM



I ended up doing a redirect back to the page again so the other control
would have the session variables needed. That worked.


Quote:
Okay, I was able to get it to compile this line:

OtherControl control = (OtherControl)Page.FindControl("OtherControl1");

by adding:

%@ Register Src="OtherControl.ascx" TagName="OtherControl"
TagPrefix="uc1" %

to the top of my aspx page, but now it doesn't know that the function
belongs to the control:

control.ShowCustomInformation();
//says 'OtherControl' does not contain a definition for
'ShowCustomInformation'

Thanks,
Steven



How can I call a function in one UserControl from another?
I have a custom sign in UserControl and another that needs
to display custom information based on the sign in along
the margin. I've been trying things I've found online, but
can't get a definition of the class.

// C#
private void Successful_SignIn()
{
//compile error: OtherControl is not defined
OtherControl control = (OtherControl)Page.FindControl("OtherControl1");
control.ShowCustomInformation();
}

These controls are on a MasterPage.
I have Session variables being setup in the sign in control, but
apparently
the 2nd control's Page_Load() is going off before the sign in control.


Thanks,

Steven


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.