Solved

Bind Property to Asp.net textbox

Posted on 2009-05-13
6
670 Views
Last Modified: 2012-05-06
I have a numerous textboxes and controls on my asp.net page. I also have properties that I fill based on the outcome of different class functions. Below is an example of a property in one of the classes of my site:
'User branch property
    Private Branch As String
    Public Property UserBranch() As String
        Get
            Return Branch
        End Get
        Set(ByVal UserBranch As String)
            Branch = UserBranch
        End Set
    End Property
Now, is there a way in asp.net to bind a textbox to this value such as databinding other than using txtbranch.text = userbranch in the page load event. Is there a way to tie this property to this value so that every time the page loads, then it will display the return value from the property. Any help would be greatly appreciated.
0
Comment
Question by:jpadkins49
  • 4
  • 2
6 Comments
 
LVL 10

Expert Comment

by:MaxOvrdrv2
ID: 24375038
txtbranch.DataSource=UserBranch
0
 
LVL 1

Author Comment

by:jpadkins49
ID: 24375398
Is there a datasource property for textbox controls in asp.net? I do not see one.
0
 
LVL 10

Expert Comment

by:MaxOvrdrv2
ID: 24375939
no... there is none... my bad... BUT... if you put the txtbranch.Text=UserBranch in the page load, wouldn't that load the text every time?

i don't understand what you're trying to do... you want the text to change on the fly without a post-back?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 10

Accepted Solution

by:
MaxOvrdrv2 earned 500 total points
ID: 24375988
you could always define a datasource object, and then on the page load set the text to the datasource... but it's the same thing as calling it directly in the page load.
0
 
LVL 1

Author Comment

by:jpadkins49
ID: 24430606
I have set these values to load on the page load event, but they sometimes lose their values on the postback and I am not sure why.
0
 
LVL 10

Expert Comment

by:MaxOvrdrv2
ID: 24432302
how do you add the objects that hold the values?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to LOAD up a .NET Framework website with data? 2 41
How to deploy to IIS 7 on 2008R2 server with DUO 2-step login? 2 35
Connection String 16 43
SQL Login 17 40
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now