Ask a Question related to ASP.NET Building Controls, Design and Development.
-
mark #1
Viewstate errors... how do I get viewstate working?
Hi all,
Have to say I can't for the life of me get this viewstate business
working with collections of classes!
The current error I'm getting is
'MSS.ProgressBar' does not implement interface member
'System.Web.UI.IStateManager.LoadViewState(object) '.
'MSS.ProgressBar.LoadViewState(object)' is either static, not public,
or has the wrong return type.
This is for LoadViewState, SaveViewState & TrackViewState.
The following code comes from a userontrol I'm using as a progress
bar. I've cut some irrelevant code out. I would really appreciate it
if someone could tell me what I'm doing wrong.
I define my class asSystem.Web.UI.IStateManager>>public class ProgressBar : System.Web.UI.UserControl,
I create a new instance of my collectionFurther on I expose the collection as a property.>>private Items _itms = new Items();
At the end I override the IsTrackViewState property and LoadViewState,
SaveViewState & TrackViewState functions.
Where Am I going wrong?
Thanks in advance,
Mærk...
namespace MSS
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
public enum Positioning
{
Horizontal = 0,
Vertical = 1
}
/// <summary>
/// Summary description for ProgressBar.
/// </summary>
[Serializable]
public class ProgressBar : System.Web.UI.UserControl,
System.Web.UI.IStateManager
{
protected System.Web.UI.WebControls.Table myTable;
protected System.Web.UI.WebControls.TableCell myCell;
private Items _itms = new Items();
private void Page_Load(object sender, System.EventArgs e)
{
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public Items Items
{
get
{
if (_itms == null)
{
_itms = new Items();
if (IsTrackingViewState)
((IStateManager)_itms).TrackViewState();
}
return _itms;
}
}
/// <summary>
/// Image URL of completed steps
/// </summary>
public string CompletedImageURL
{
get
{
return (string)ViewState["CompletedImageURL"];
}
set
{
ViewState["CompletedImageURL"] = value;
}
}
public Unit CellWidth
{
get
{
return (Unit)ViewState["CellWidth"];
}
set
{
ViewState["CellWidth"] = value;
}
}
public string[] Text
{
get
{
return (string[])ViewState["Text"];
}
set
{
ViewState["Text"] = value;
}
}
public int CurrentStep
{
get
{
return (int)ViewState["CurrentStep"];
}
set
{
ViewState["CurrentStep"] = value;
}
}
public Color Background
{
get
{
return (Color)ViewState["Background"];
}
set
{
ViewState["Background"] = value;
}
}
protected override void CreateChildControls()
{
// Here I create my controls. Not relevant to this discussion...
}
#region IStateManager Members
public new bool IsTrackingViewState
{
get
{
// TODO: Add ProgressBar.IsTrackingViewState getter
implementation
return ((IStateManager)_itms).IsTrackingViewState; //true;
}
}
override protected void TrackViewState()
{
base.TrackViewState();
if (_itms != null)
((IStateManager)_itms).TrackViewState();
}
override protected object SaveViewState()
{
return new Pair(base.SaveViewState(),((IStateManager)_itms).S aveViewState());
}
override protected void LoadViewState(object state)
{
Pair p=(Pair)state;
if(p==null)return;
base.LoadViewState(p.First);
((IStateManager)_itms).LoadViewState(p.Second);
}
#endregion
}
}
mark Guest
-
Failed to load viewstate. The control tree into which viewstate...
Hi to all, I have a webform.aspx and inside i have a dropdown list with autopostback and a place holder... Depending of the selected index... -
Viewstate
hi I am using the viewstate of a dynamically created Datagrid ( columns are created dynamically and bound to a dataset) to export to excel.... -
ASP.NET Viewstate Bug
Does it happens when the request goes on a machine but was previously handled by the other one (for example because it keeps the client IP/machine... -
Where did my ViewState go???
I'm trying to build serval custom controls and I'm havinig trouble maintaining their viewstate. So I wanted to back it up to the most basic level -... -
Viewstate errors
Hi There I dont know which category this fits in best as its kind of a mix of a few...(ack!!) Im getting "The viewstate is invalid for this page...



Reply With Quote

