Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 3rd, 2007, 08:05 AM
Registered User
 
Join Date: Mar 2007
Location: Bengalooru, Karnataka, India.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default User control accessing problem

Hi, I have a grid (which has textboxes in the item template) that has been converted as a user control and this is placed in another page.

At page load I am able to bind the values to the textboxes in the user control. However if i modify the contents of the textboxes and when i try to read the contents of the textbox I am getting the initial value itself and not the altered value.

Can anyone suggest how to get the altered values.

Thanks in advance
Nishant
 
Old May 3rd, 2007, 08:52 AM
Authorized User
 
Join Date: Dec 2004
Location: Swindon, Wilts, United Kingdom.
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to DZukiewicz
Default

If you are populating the data in the page load and do not place it in an (!IsPostBack), there is a chance that you are overwriting the value. E.g.

Code:
protected void Page_Load(object sender, EventArgs e)
{
     //Placing it here will only set it on the first load of the page.
     if(!IsPostBack)
     {
          txtBox.Text = "Initial";  //Will only populate on first page load.
     }

     /*
     //Placing it here will always set it
     txtBox.Text = "Hello";   
     */
}

protected void txtBox_TextChanged(object sender, EventArgs e)
{
     Response.Write("Textbox changed to " + txtBox.Text);
}

Hope this helps,

Dominic




Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing controls in host page from User Control Axe BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X 1 March 16th, 2011 06:22 AM
Problem while using User Control vivekshah ASP.NET 1.0 and 1.1 Professional 0 August 7th, 2008 02:46 AM
Much much problem with the User Control! daffodils ASP.NET 1.0 and 1.1 Basics 7 October 20th, 2006 10:46 AM
Accessing the Controls of a User Control? Aaron Edwards ASP.NET 2.0 Basics 6 June 16th, 2006 07:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.