473,657 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

textbox in user control losing values during post back

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
2 5881

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4266
by: David Smith | last post by:
What I want to be able to do: A textbox is available that the user can enter information into. Specifically (for the purposes of this post), the user is asked to enter a number, and that number has an upper limit. I want to do validation on what the user enters as they type it in. I set up an event handler for KeyPress that restricts them from being able to enter non-numeric characters (only allowing numbers, decimal point, control...
1
1623
by: Philip Townsend | last post by:
I have a user control that contains a form with several text boxes. The text boxes get populated from a SQL Server table when the control loads. When the controls posts back, any values that have changed get passed to a stored procedure to update the table. The problem is that when the form is submitted, the text boxes seem to lose their values and contain nothing but empty strings. I have tested the same code from an .aspx page and it...
6
7875
by: Alex | last post by:
I am a newbie to ASP.NET... What I was trying to do... but yet to succeed in... I am building a customer info database... and on default, I want to display the customer's basic information in the TextBox on Page_Load... but, also allow user to update the information For example: Street1 of the home address
2
8387
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when submitting the form to update the database. The server doesn't have the client side value any more. It seems to me that as I begin to write the client side javacript code for form validation and client side editing capabilities in order to save...
0
1387
by: jason | last post by:
Hello everyone. I am trying to write some custom command events into a DataGrid. The command that is currently giving me trouble is an "Add" custom command in the footer of a template column. Question #1: In the Add button Command Event I am trying to access the Text value of the TextBox in the other Footer columns. However, inside the Event, the TextBox.Text values are all empty strings, even if they had data typed into them. Is this a...
9
5303
by: McGeeky | last post by:
Is there a way to get a user control to remember its state across pages? I have a standard page layout I use with a header and footer as user controls. Each page uses the same layout by means of copy paste (I hear this will improve in ASP.Net 2 via master pages). When I navigate from one page to the next the header and footer user controls lose their state because they are effectively different instances of the user control. Is there...
1
4218
by: jqheller | last post by:
Folks I am losing my mind trying to work with the TemplatedWizardStep. I have created a multistep user registration form that collects plenty of user information including a password. At the end of the process I am finding that the value of my password control is blank. When I set the textmode of my textbox to singleline, the value is preserved. It is just when the textbox is set to password that I lose the value. I am casting to the...
2
4245
by: =?Utf-8?B?TG91aXNhOTk=?= | last post by:
Hello. ive just read some posts on the age old issue of losing dynamic control values on postback. Most people say recreate the controls on the onInit, but i just dont think this serves my purpose. if i could explain: i have a list of reports in a datalist. a user clicks a report link. it goes off to reporting services, fetches the parameters for this report and displays x number of textboxes (and labels) for those parameters (hence it...
6
2894
by: john | last post by:
I have the following textbox setup with Text & ToolTip Bindings as follows; I'm using Visual Studio 2008 VB: <asp:TextBox ID="txtDay1" runat="server" Text='<%# Eval("Day1") %>' Width="30px" ToolTip='<%# Eval("M1") %>'></asp:TextBox>
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8730
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1950
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1607
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.