Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 November 14th, 2004, 02:25 PM
Authorized User
 
Join Date: Oct 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default <ASP:TextBox> does not retain the value

Hi all,

I have a control <asp:textbox id="myVar" runat=Server> to hold something on one of my page. When I submit the page to itself, the value of myVar does not retain. How can I fix this problem?

Thanks

John

 
Old November 15th, 2004, 09:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Can you post your code?

 
Old November 15th, 2004, 04:13 PM
Authorized User
 
Join Date: Oct 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Very simple, but the value of myVal just reset back to 0 when I debugged.

private void Page_Load(object sender, System.EventArgs e)
{

 if (!IsPostBack) {

    if ( Request.QueryString("Page") != null ) {

        // Dosomething

        myVar.Text = Convert.ToInt32(mayVar.Text) + 1 ;

   }
}


 
Old November 15th, 2004, 04:52 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

It seems like you are mixing techniques here. Your page will only set the textbox text to "value+1" on the first page hit. Is this what you want to do?

Are you sure there isn't something else in the page code that is setting the textbox text to another value?
 
Old November 15th, 2004, 05:57 PM
Authorized User
 
Join Date: Oct 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Yes, I have alot more codes but I just want to show you the problem by cut and paste a few lines. My goal is to use that variable to hold the page index. Based on value of queryString then I will increase or decrease the variable.

 
Old November 15th, 2004, 06:01 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I am also a bit confused about your message.
In your description you talk about myVal.

Then in your code you to try to cast the value of mayVar (notice the extra a) to an int, add 1 and assign it back to the Text property of the myVar control. That's three different names for (probably) the same stuff.

Are you sure this isn't related to a typo?

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old November 15th, 2004, 06:08 PM
Authorized User
 
Join Date: Oct 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Forget about it. Let me tell you the problem one more time. My goal is to use 1 variable to hold the page index with a name( I don't care the name) . Based on value of queryString then I will increase or decrease the value of that variable. The problem is: the value variable never greater than 1. Every time I post the page, the variable on serverside equal 0, althought the value in aspx before I submit is 1. Sorry for confusing.










Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch 8: <asp:image> inside <a> & ext.CSS (pg. 274) epc BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 July 12th, 2008 04:37 AM
problem in <asp:TextBox> saurabh321 ASP.NET 2.0 Basics 2 November 3rd, 2006 12:02 AM
a problem in book<<beginning asp.net using vb>> luoware ASP.NET 1.0 and 1.1 Basics 3 December 8th, 2003 09:32 PM
<<ASP.NET Security>>,download files in chapter 8 alaix All Other Wrox Books 1 July 24th, 2003 10:29 AM





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