StateBag.Remove Method (String)
.NET Framework (current version)
Removes the specified key/value pair from the StateBag object.
Assembly: System.Web (in System.Web.dll)
Parameters
- key
-
Type:
System.String
The item to remove.
The following code example demonstrates using the Remove method.
void MovePiece(string fromPosition, string toPosition) { StateBag bag = ViewState; object piece = bag[fromPosition]; if (piece != null) { bag.Remove(fromPosition); bag.Add(toPosition, piece); RenderBoard(); } else { throw new InvalidPositionException("There is no game piece at the \"from\" position."); } }
.NET Framework
Available since 1.1
Available since 1.1
Show: