473,395 Members | 1,915 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.

postback and viewstate

Hi,everyone,
I have implemented a user control with a button that can show up a modal
dialog. After the modal dialog is closed, a postback event occur and my user
control can successfully receive the return value from the closed modal
dialog. I implemented IPostBackEventHandler for the user control.My problem
is, in the event handler i changed a variable's view state,but when I check
my codes in the user control's overrided Render() function,I found the
variable's view state has been restored to the previous value before I
changed. It sounds very odd,and i am sure i have not changed the variable
anywhere.
Could anyone hele me?

Crespo
May 13 '07 #1
3 1413
Hi,

post the code.
--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
"crespo" <wu******@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi,everyone,
I have implemented a user control with a button that can show up a modal
dialog. After the modal dialog is closed, a postback event occur and my
user control can successfully receive the return value from the closed
modal dialog. I implemented IPostBackEventHandler for the user control.My
problem is, in the event handler i changed a variable's view state,but
when I check my codes in the user control's overrided Render() function,I
found the variable's view state has been restored to the previous value
before I changed. It sounds very odd,and i am sure i have not changed the
variable anywhere.
Could anyone hele me?

Crespo
May 13 '07 #2
"crespo" <wu******@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Could anyone hele me?
Not without seeing the code...
--
http://www.markrae.net

May 13 '07 #3
Thanks for your concern. I only place partial codes below.

The statement of the variable which can be tracked in view state is :
public string time
{
get { return this.ViewState["__timeStamp"].ToString(); }

set { this.ViewState["__timeStamp"] = value; }
}

In the event handler that does with post back event is::

//do something to save a record of table
.........................
// get the timestamp and convert it to string
................................
// then save the value of timestamp
this.time = "xxxxxxxxxxx".//new time stamp after saving successfully

Actually I implement the IPostbackEventHandler for my own page class
inherited from System.web.ui.page. and the javascript for post back is
like:
__doPostBack("_page","");

As it did the trick, I don't think it is important to list those codes in
order to firgure out the problem. One of my doubt is: when
IPostbackEventHandler is implmented in my own page class,Is there a
difference
from those case in which IPostbackEventHandler is implemented in other
server controls. Another question is : As processing post back event always
happens behind loading view state,why is the variable "time" gonna be
restored to previous value ?

Hope these simple code can help you to solve out my question. Thanks.

Crespo

"Mark Rae" <ma**@markNOSPAMrae.net????
news:%2****************@TK2MSFTNGP06.phx.gbl...
"crespo" <wu******@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>Could anyone hele me?

Not without seeing the code...
--
http://www.markrae.net

May 13 '07 #4

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

Similar topics

4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
2
by: Earl Teigrob | last post by:
I have run into a situation where I need to run the !IsPostBack code under one circumstance, even if it is a postback. Something that may complicate matters more is that this is a double postback...
2
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid...
10
by: Calvin X | last post by:
Hi all I have the following code in the page load event. The function in this code works get to populate the 4 dropdownlists on my webform. I have enabled postback because when the user selects...
2
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control...
1
by: John Cosmas | last post by:
I've got a page which loads up a different user control into a placeholder control every time a button is clicked on the parent page. I use a statement like...
4
by: Mark Olbert | last post by:
This involves a family of related, databound ASPNET2 composite controls. I've managed to arrange things so that the composite controls restore themselves from ViewState on postback after they're...
1
by: RSH | last post by:
Hi, I am experimenting with the Viewstate and based on a few articles I have read, I put together a test. it is a simple test where I am dynamically creating a DropDownList that contains 25000...
2
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
4
by: Dan | last post by:
Hi, i'm not sure to understand the difference between refreshing the pagina by clicking on 'refresh' in the browser and a postback. What i think it is: Suppose a page with a form containing a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.