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 / ASP.NET / Web Controls / May 2008

Tip: Looking for answers? Try searching our database.

updating usercontrol textbox.text programmatically from host page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Hopper - 28 May 2008 21:19 GMT
Hello,

In the aspx hostpage codebehind using ...

Dim myUC As New UserControl
       myUC = Me.LTUC
       Dim myTB As New TextBox
       myTB = myUC.FindControl("textbox1")
       myTB.Text = Me.FCKeditor1.Value
       
I can change the text of myTB.text as it is hosted but the changes aren't
persisted. Do I have to use an xml or text file as the source of the
usercontrol's textbox.text property and then write to the text or xml file
using a textwriter? Can't I just update the usercontrol's textbox.text
property directly so that the new value appears with the next instantiation?

Thank you,
Stan - 30 May 2008 11:54 GMT
> Hello,
>
[quoted text clipped - 13 lines]
>
> Thank you,

Hi John

There is an easier way to read and write to the UserControl TextBox
from the host page.

In the VB code for the UserControl itself decare a text property and
link it to the text of the actual control e.g.

public property TheText() as String
     Get
           return textbox1.text
     End Get
     Set (ByVal value as string)
           textbox1.text = value
     End Set
End Property

The content of textbox1 will then be accessible as LTUC.TheText
(It will also appear in the property window of the declared instance
in VS designer and also in the html source code editor as a
recognizable attribute!)

Assuming LTUC is declarative (i.e. declared at design time rather than
programmatically like MyUC) then LTUC.TheText will be preserved by
ViewState because textbox1 in the UserControl is itself declarative.

HTH
John Hopper - 30 May 2008 15:16 GMT
Cool. Thanks!

> > Hello,
> >
[quoted text clipped - 41 lines]
>
> HTH

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.