"Masudur" <munnacs@gmail.com> wrote in message
news:c8ab04a7-d635-483a-82fa-48a54abb58d5@j20g2000hsi.googlegroups.com...
> On Feb 13, 1:52 pm, Chris Zopers <test123tes...@12move.nl> wrote:
>> Hello,
>>
>> I have an aspx page with some controls like textboxes on it and a button
>> to save the entered values.
>>
>> In the code-behind I declared a public variabele of an object, for
>> example:
>>
>> public Person _prs = new Person();
>>
>> Where Person is a class with some properties, like FirstName and
>> LastName. The textboxes display the values in this way: Text = '<%#
>> _prs.FirstName #>' and for another Textbox: Text = '<%# _prs.LastName
>> #>'
>>
>> When the user clicks on the save button, the page_load event happens
>> first, so my public Person is always set to a new Person() again and
>> therefore I can't use the variable _prs to see the new entered values in
>> the textboxes.
>>
>> My question is: how can I bind my textboxes to the properties of the
>> public variable _prs, so the values that are entered in the textboxes
>> immediately are updated in the Person object and how can I preserve
>> these values, so I can use the Person object in the button-save click
>> event?
>>
>> Greetings,
>> Chris
>>
>> *** Sent via Developersdex
http://www.developersdex.com***
>
> Do expose a property of your desired type encapsulating it in a
> viewstate or session.
> for example
> public person myperson
> {
> get
> {
> if(viewstate["myperson"]==null;
> viewstate["myperson"] = new Person();
> return (person)viewstate["myperson"]
> }
> set
> {
> viewstate["myperson"] = value;
> }
> }
>
> Bind you stuff with the property ...
> after postback...
> again update the property values...
interface). The OP also needs to realize that by default the Person class
potential security risk.