UserControl.IsPostBack Egenskap

Definition

Hämtar ett värde som anger om användarkontrollen läses in som svar på en klientpostback, eller om den läses in och används för första gången.

public:
 property bool IsPostBack { bool get(); };
[System.ComponentModel.Browsable(false)]
public bool IsPostBack { get; }
[<System.ComponentModel.Browsable(false)>]
member this.IsPostBack : bool
Public ReadOnly Property IsPostBack As Boolean

Egenskapsvärde

trueom användarkontrollen läses in som svar på en klientåterställning; annars . false

Attribut

Exempel

I följande exempel läggs två nyckelvärdepar till programtillståndet som är associerat med en användarkontroll om användarkontrollens IsPostBack egenskap returnerar false. När det här villkoret uppfylls använder Add koden metoden, via användarkontrollens Application egenskap, för att lägga till nycklarna och deras värden.

if (!myControl.IsPostBack)
{
  // Add new objects to the HttpApplicationState.
  // These will be maintained as long as the application is active.
  myControl.Application.Add("Author","Shafeeque");
  myControl.Application.Add("Date",new DateTime(2001,6,21));
  // Add an object to the cache with expirations 
  // set to 0.1 minute.
  myControl.Cache.Insert("MyData1", "somevalue", null, DateTime.Now.AddMinutes(0.1), Cache.NoSlidingExpiration);
}
If (Not myControl.IsPostBack) Then
  ' Add new objects to the HttpApplicationState.
  ' These will be maintained as long as the as the application is active.
  myControl.Application.Add("Author","Shafeeque")                
  myControl.Application.Add("Date",new DateTime(2001,6,21))
  ' Add an object to the cache with expirations
  ' set to 0.1 minute.
  myControl.Cache.Insert("MyData1", "somevalue", Nothing, DateTime.Now.AddMinutes(0.1), Cache.NoSlidingExpiration)        

Gäller för

Se även