aspnet don't save property control

J

Jhon Smith

Hi!

I have one WebControl and 2 properties... but aspnet don't save my
second property value when I change first property.

Thank's!!

This is my code:

public class myControl: System.Web.UI.WebControls.Button {
private string _one, _two;

public myControl() : base()
{ /*_*/ }

public string one {
get { return _one; }
set { this.two = "Two!: " + value; _one = value; } }
public string two {
get { return _two; }
set { _two = value; } }
}
 
J

Jens Hofmann

Properties are not saved by default... a usercontrol
is alway recreated with each call of a page containing the control.

You should save your Propertie-Values in ViewState

ViewState["Test"] = value;

and

return (int) ViewState["Test"];

Have a look at Viewstate!

Cu Jens
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top