Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / October 2007

Tip: Looking for answers? Try searching our database.

ASP.NET UserControl Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
EdisonCPP - 13 Oct 2007 02:13 GMT
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
EdisonCPP - 13 Oct 2007 22:17 GMT
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
[quoted text clipped - 18 lines]
>
> Steven
EdisonCPP - 13 Oct 2007 22:39 GMT
I ended up doing a redirect back to the page again so the other control
would have the session variables needed.  That worked.

> Okay, I was able to get it to compile this line:
>
[quoted text clipped - 37 lines]
>>
>> Steven

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.