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

November 14th, 2004, 02:25 PM
|
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
<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
|
|

November 15th, 2004, 09:50 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Can you post your code?
|
|

November 15th, 2004, 04:13 PM
|
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 ;
}
}
|
|

November 15th, 2004, 04:52 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
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?
|
|

November 15th, 2004, 05:57 PM
|
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

November 15th, 2004, 06:01 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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.
|
|

November 15th, 2004, 06:08 PM
|
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|
 |