textbox in user control losing values during post back

G

Guest

Hi,

I have a user control which has a textbox control and a button. I have
created a property to get and set the text box value. In the Page_Load method
of the Page that contains the user control, I am setting the textbox value
that is inside the user control. When I click the button that is inside the
user control and try to access the textbox value it is getting empty string
instead of the value set in the Page_Load. I have tried setting
EnableViewState explicity but still it is not holding the value. I am not
loading the user control dynamically. Please let me know if you have any
ideas.

Thanks,
Sridhar.
 
L

Lav KG

Sridhar said:
Hi,

I have a user control which has a textbox control and a button. I have
created a property to get and set the text box value. In the Page_Load method
of the Page that contains the user control, I am setting the textbox value
that is inside the user control. When I click the button that is inside the
user control and try to access the textbox value it is getting empty string
instead of the value set in the Page_Load. I have tried setting
EnableViewState explicity but still it is not holding the value. I am not
loading the user control dynamically. Please let me know if you have any
ideas.

Thanks,
Sridhar.

Try surrounding your code by following block

if (! IsPostBack)
{
// your code.
}

let's hope it works...:)
 
G

Guest

I am trying to access the textbox inside button_click method of the user
control. Also when I am setting the textbox value in the Page_load method of
the page, I have tried setting it both inside

if not page.ispostback
end if

and also outside of it. None of them works.

Thanks,
Sridhar.
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top