473,395 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 1534
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.