|
Este artigo foi traduzido por máquina. Coloque o ponteiro do mouse sobre as frases do artigo para ver o texto original. Mais informações.
|
Tradução
Original
|
StateBag Classe
Assembly: System.Web (em System.Web. dll)
System;
System.Web;
System.Web.UI;
ViewStateControlSamples
{
CustomLabel : Control
{
defaultFontSize = 3;
String Text
{
{
object o = ViewState[];
(o == )? String.Empty : (string)o;
}
{
ViewState[] = value;
}
}
FontSize
{
{
object o = ViewState[];
(o == ) ? defaultFontSize : ()o;
}
{
ViewState[] = value;
}
}
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = )]
Render(HtmlTextWriter output)
{
output.Write( + .FontSize.ToString() + + .Text + );
}
}
}
package ViewStateControlSamples;
// This control renders values stored in view state for Text and
// FontSize properties.
import System.*;
import System.Web.*;
import System.Web.UI.*;
public class Label extends Control
{
// Add property values to view state with set;
// retrieve them from view state with get.
/** @property
*/
public String get_Text()
{
return ((String)(get_ViewState().get_Item("Text")));
} //get_Text
/** @property
*/
public void set_Text(String value)
{
get_ViewState().set_Item("Text", value);
} //set_Text
/** @property
*/
public int get_FontSize()
{
return (int)Convert.ToInt32(get_ViewState().get_Item("FontSize"));
} //get_FontSize
/** @property
*/
public void set_FontSize(int value)
{
get_ViewState().set_Item("FontSize", (Int32)value);
} //set_FontSize
protected void Render(HtmlTextWriter output)
{
output.Write("<font size=" + this.get_FontSize() + ">"
+ this.get_Text() + "</font>");
} //Render
} //Label
// This control renders values stored in view state for Text and FontSize properties. import System import System.Web import System.Web.UI package ViewStateControlSamples { public class Label extends Control { // Add property values to view state with set; // retrieve them from view state with get. public function get Text() : String { return String(ViewState["Text"]); } public function set Text(value : String) { ViewState["Text"] = value; } public function get FontSize() : int { return int(ViewState["FontSize"]); } public function set FontSize(value : int) { ViewState["FontSize"] = value; } protected override function Render(output : HtmlTextWriter) { output.Write("<font size=" + this.FontSize + ">" + this.Text + "</font>"); } } }
- AspNetHostingPermission
Para operar em um ambiente hospedado. Exigem valor: LinkDemand; Permission value: Minimal.