Solved

Bind Property to Asp.net textbox

Posted on 2009-05-13
6
686 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
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…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

622 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