Referencing a control on a different page

  • Thread starter Thread starter dana lees
  • Start date Start date
D

dana lees

Hello,

I am developing a c# asp.net application. I have 2 forms.

In the first webform ('header') i have a label.
I want to reference that label from a different form ('user'), in order to
change its' text.

How can i do that?

Thank you,
Dana
 
You cannot simply access other pages without actually transferring control
to that second page. Each page is self-contained.

The real question is, why would you need to change the text on the second
page that will not be displayed during the current page request?
 
On 'header' i have a label that shows the number of current users in the
system.
On 'User.aspx' i can add or delete a user and then i would like to refresh
the label on the first page because the number of users on it is no longer
valid...
 
Such information should be saved in an application variable or in an
external file or database that will be read when the header loads and is
displayed.
 
So i have to reload header every time i add/delete a user?
How do i reload it from a different form?
 
Okay, I am confused. What is the header? Is is a user control or a page in
an iframe or what?

Pages are always reloaded when a request is made to the server. Not sure
what you mean by "reload header every time".
 
"Header" is a webform in which i want to include a user control, called
"numUsers".

The control i have created is called: "numUsers.ascx"

In order to user it in "Header.aspx", i have added the following code:

<%@ Register TagPrefix="uc1" TagName="numUsers" Src="numUsers.ascx" %>
<uc1:numUsers id="NumUsers1" runat="server"></uc1:numUsers>

In order to call setLabel() function in header.aspx.cs file, i have used:

numUsers ctrl = new numUsers();
ctrl = (numUsers)Page.FindControl("NumUsers1");
ctrl.setLabel("dana");

When debugging, i see that i do enter setLabel() function and set the label
to "dana" but then i enter Page_Load and the label is empty again.
 

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

Back
Top