473,472 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem with view state in an asp page.

I am developing a web based app. in .net, with C# as the code
behind.the problem I am having is with view state for a page. the page
is capturing an event fired in an object. the event changes the
properties of various controls in the UI. the event is fired when the
user enters some info. on the page, initiating a post back etc.
However, when i test the page, the changes that should appear in the
UI don't happen. debugging through the code everything appears in
order - page loads, the event is captured and the properties are set
in the controls (which are labels). how ever, when you look at the
controls during pre-render the controls have their original values. if
I add code that adds proeprties to view state when the event fires,
when you try yo get these properties back during pre-render they are
null. it as if the page has locked view state, or is using the
original view state info. - either way the changes that should be
happening are ignored ....any ideas much appreciated.
Jul 21 '05 #1
3 1543
looks like coding problem. you could put some code snippet here.

Rajesh Patel

"Bren" <br**********@hotmail.com> wrote in message
news:93**************************@posting.google.c om...
I am developing a web based app. in .net, with C# as the code
behind.the problem I am having is with view state for a page. the page
is capturing an event fired in an object. the event changes the
properties of various controls in the UI. the event is fired when the
user enters some info. on the page, initiating a post back etc.
However, when i test the page, the changes that should appear in the
UI don't happen. debugging through the code everything appears in
order - page loads, the event is captured and the properties are set
in the controls (which are labels). how ever, when you look at the
controls during pre-render the controls have their original values. if
I add code that adds proeprties to view state when the event fires,
when you try yo get these properties back during pre-render they are
null. it as if the page has locked view state, or is using the
original view state info. - either way the changes that should be
happening are ignored ....any ideas much appreciated.

Jul 21 '05 #2
Rajesh,

There isn't a whole lot of code involved but heres a snippet...

this code is in the aspx page. the page has an instance of an object
called salesOrderLine, which has an event EnquiryPropertyChanged. the
aspx page has an event handler added during load and has the follwing
delegate to handle the event....
private void salesOrderLine_EnquiryPropertiesChanged (object sender,
CustomEventArgs e)
{
this.labelEnquiry.Text = "Enquiry Changed";
this.labelSalesOrderUpdated = "Update Complete";
}

as you can see I am simply putting some simple text into two labels.
when you step through the code it runs fine, except that the text does
not appear in the UI. I put a debugger in the above event and also in
the OnPreRender event of the aspx page - when I look at the the two
labels
immediately after setting the text, their text properties show me the
correct thing - if I then look at the labels during prerender, they show
their text properties as empty, which was their default state..

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #3
I have a page with a button and a handler for its click event. I did exactly
what you described with 2 labels and viewstate and all is working as
expected. If your page is somewhat complex with other events and logic, I
suggest you create a simple web page like I did with only a button and 2
labels and see if you still get it.


"Brendan Ryan" <br**********@hotmail.com> wrote in message
news:eX**************@TK2MSFTNGP09.phx.gbl...
Rajesh,

There isn't a whole lot of code involved but heres a snippet...

this code is in the aspx page. the page has an instance of an object
called salesOrderLine, which has an event EnquiryPropertyChanged. the
aspx page has an event handler added during load and has the follwing
delegate to handle the event....
private void salesOrderLine_EnquiryPropertiesChanged (object sender,
CustomEventArgs e)
{
this.labelEnquiry.Text = "Enquiry Changed";
this.labelSalesOrderUpdated = "Update Complete";
}

as you can see I am simply putting some simple text into two labels.
when you step through the code it runs fine, except that the text does
not appear in the UI. I put a debugger in the above event and also in
the OnPreRender event of the aspx page - when I look at the the two
labels
immediately after setting the text, their text properties show me the
correct thing - if I then look at the labels during prerender, they show
their text properties as empty, which was their default state..

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Robin Bonin | last post by:
In my user contol I am creating a set of dropdownlists. Each list is created based on input from the other lists. The problem I am having is setting the selected index on the lists. If someone...
3
by: Lloyd Sheen | last post by:
I have a page that works fine. I am trying to optimize the page by overriding some of the Information that is being saved in the hidden VIEWSTATE. If I make the properties of the dropdown False...
0
by: Bren | last post by:
I am developing a web based app. in .net, with C# as the code behind.the problem I am having is with view state for a page. the page is capturing an event fired in an object. the event changes the...
9
by: Matt Tapia | last post by:
I having a problem that receives the following error: Specified cast is not valid And I need some help. Here is what is happening: I have a form with a drop-down control that contains a list...
3
by: Philip Tripp | last post by:
I've read numerous sources stating that view state can be disabled per control, and per page, but can't seem to keep web form controls from remembering their state on a postback. I'm using VS.Net...
2
by: JJ | last post by:
Hi, I have a textbox setup on a web form and it suppose to keep a running total of some other textboxs on page. In code behind I have a global double var that is suppose to collect the total but...
6
by: Bren | last post by:
I am developing a web based app. in .net, with C# as the code behind.the problem I am having is with view state for a page. the page is capturing an event fired in an object. the event changes the...
3
by: gaDev | last post by:
1) I build a Html Table dynamically (Header Row, and then 2 rows with data All 2 rows have 2 cells: cell(0) contains a delete button (ASP Button), cell(1) contains a HTML Text box 2) On Form Load...
1
by: Daniel Alvarez | last post by:
Hello. First of all, I'm working in an ASP.NET 1.1 project, which has a large page (due to client requirements, a huge page is needed to process the information, and it has a lot of interactivity...
0
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,...
0
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...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.