By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,200 Members | 1,607 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,200 IT Pros & Developers. It's quick & easy.

textbox in user control losing values during post back

P: n/a
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.
Aug 23 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

Sridhar wrote:
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...:)

Aug 23 '06 #2

P: n/a
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.

"Lav KG" wrote:
>
Sridhar wrote:
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...:)

Aug 23 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.