954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Update website control from usercontrol?

Hi..

I am trying to update a webcontrol on a main site from a usercontrol but how can this be done.

Let's say I want to update an asp:textbox from a usercontrol on the page, but how is this done most respectfully. The usercontrol does ofcause not know the controls from the main site but I guess that the "findcontrol"-method (in the usercontrol) executed on the parent-control must do what I need (as long that I check that the control exist on the main page); but how is this done.

Something like this maybe:
MAIN SITE:
<SOME TEXTBOX id="main">
<uc:USERCONTROL id="UC">

USERCONTROL codebehind somewhere:
((Textbox)This.parent???.findcontrol("main")).Text = "something from uc";

sniper1983
Light Poster
30 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

I think ASP.NET forum http://www.daniweb.com/forums/forum18.html can answer but I'll give a solution
if UserControl has property = "something from UC" you can from the page holds the Usercontrol say textbox.Text = UC.PropertyName; and it's the correct the usercontrol should have no information about the page it's in. but the page should have.

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

Thanks.. Ofcourse I should have asked in the asp.net section.. :)

sniper1983
Light Poster
30 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

thanks so much for useful info
SNIP

mcjohn87
Newbie Poster
2 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You