471,119 Members | 1,169 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,119 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 1422
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Robin Bonin | last post: by
3 posts views Thread by Lloyd Sheen | last post: by
reply views Thread by Bren | last post: by
9 posts views Thread by Matt Tapia | last post: by
3 posts views Thread by Philip Tripp | last post: by
2 posts views Thread by JJ | last post: by
3 posts views Thread by gaDev | last post: by
1 post views Thread by Daniel Alvarez | last post: by

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.