Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User Control 1

Status
Not open for further replies.

developer155

Programmer
Jan 21, 2004
512
US
This is a question about UserControl execution.
The user control I have calls a function in its code behind from ascx
<td><%=SomeFunction() %>

That function updates a variable in the code behind of that control and I need that variable in outside code

At what point of time does =SomeFunction() execute in that control?
I noticed that after I call Page.LoadControl
and try to access the variable in the control, the variable is blank, meaning SomeFunction() has not yet executed. So when should I access control so that it is in the state after SomeFunction() has been called?

thanks!
 
This is another reason why we have been advising you to move the function calls out of the design and into the code behind model. If you follow this advise it will make your project a lot easier to debug and follow.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
ca8msm,
I understand that. But unfortunately I cannot due to the fact that I am working on a huge legacy project that already has function calls in the design. I need to capture the control right after the function call in the design has been executed. What step in the page life cycle is that?

thanks!!
 
Just because it's an old application, what's to stop you moving these calls into the code behind page? As soon as you do you'll be able to debug the application and see exactly where they fire.

I really don't want to suggest bad programming practices to anyone, so if that's the route you are going down, I'm afraid I won't be able to help.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
ca8msm,
I followed your advice and tried to convert to labels. So I have this now:

"<tr><td colspan=3><asp:Label id=\"lblDisclaimer\" runat=\"server\" /></td>"

After inner control has been loaded in the outer control I call this:
innerControl.lblDisclaimer.Text = "some text";

But I do not see the text. What gives?

thanks!
 
I'm not sure, but it's just something simple. I'd suggest creating a simple mockup page that has two user controls on them (again, both simple controls that maybe just have a Label on each of them). Then, you can create a simple demo project to see if it works. If it doesn't, post the results back here and we can use the same code you've written to try and replicate the problem or see where you have gone wrong.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top