Hello!
I have in my webform many TBs bound to a property in the code behind:
<asp:TextBox ID="tbFirstName" Text="<%# Contact.FirstName %>" runat="server" />
<script language="c#">
public Contact Contact
{
get
{
return (Contact)ViewState["Contact"];
}
}
</script>
<script language="VB">
Public ReadOnly Property Contact() As Contact
Get
return ViewState("Contact");
End Get
End Property
</script>
While Contact is that property.
I want that when the user inserts text, it should immediately be bound to the Contact object e.g. when the user presses a key down or even when losing focus (TextChanged) would be good too.
Is there a way to do it dynamically (rather than manually retrieve the data from all the TBs and update the Contact object)?
I am actually willing to achieve two-way databinding with simple textboxes spread in the form body.
Note: I am not going to store the items to the DB of course, I just want the object (Contact) which resides in the state manager.