SessionParameter.SessionField Özellik

Tanım

Parametresinin bağlandığını oturum değişkeninin adını alır veya ayarlar.

public:
 property System::String ^ SessionField { System::String ^ get(); void set(System::String ^ value); };
public string SessionField { get; set; }
member this.SessionField : string with get, set
Public Property SessionField As String

Özellik Değeri

Parametresinin HttpSessionState bağlandığını tanımlayan bir dize.

Örnekler

Aşağıdaki kod örneğinde bir nesnenin bildirim temelli olarak nasıl oluşturulacağıSessionParameter, nesnesinin NameSessionFieldve özelliklerinin nasıl ayarlanacağı ve DefaultValue bir SelectParameters denetimin koleksiyonuna SqlDataSource nasıl ekleneceği gösterilmektedir. Denetim GridView , denetim tarafından gönderilen SQL sorgusunun SqlDataSource sonuçlarını görüntüler.

<%@ Page language="C#"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="Form1" method="post" runat="server">
      <p>Show My Orders:</p>

      <asp:SqlDataSource
          id="OdbcDataSource1"
          runat="server"
          ProviderName="System.Data.Odbc"
          ConnectionString="dsn=MyOdbcDsn;"
          SelectCommand="SELECT OrderId, CustomerId, OrderDate
                         FROM Orders
                         WHERE EmployeeID = ?
                         ORDER BY CustomerId ASC;">
          <SelectParameters>
              <asp:SessionParameter
                Name="empid"
                SessionField="empid"
                DefaultValue="5" />
          </SelectParameters>
      </asp:SqlDataSource>

      <p>
      <asp:GridView
          id="GridView1"
          runat="server"
          DataSourceID="OdbcDataSource1" />
      </p>
    </form>
  </body>
</html>
<%@ Page language="VB"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="Form1" method="post" runat="server">
      <p>Show My Orders:</p>

      <asp:SqlDataSource
          id="OdbcDataSource1"
          runat="server"
          ProviderName="System.Data.Odbc"
          ConnectionString="dsn=MyOdbcDsn;"
          SelectCommand="SELECT OrderId, CustomerId, OrderDate 
                         FROM Orders 
                         WHERE EmployeeID = ? 
                         ORDER BY CustomerId ASC;">
          <SelectParameters>
              <asp:SessionParameter
                Name="empid"
                SessionField="empid"
                DefaultValue="5" />
          </SelectParameters>
      </asp:SqlDataSource>

      <p>
      <asp:GridView
          id="GridView1"
          runat="server"
          DataSourceID="OdbcDataSource1" />
      </p>
    </form>
  </body>
</html>

Aşağıdaki kod örneği, bir SessionField nesnenin SessionParameter özelliğinin program aracılığıyla nasıl ayarlandığını gösterir.

// In this example, the session parameter "empid" is set
// after the employee successfully logs in.
SessionParameter empid = new SessionParameter();
empid.Name = "empid";
empid.Type = TypeCode.Int32;
empid.SessionField = "empid";
' In this example, the session parameter "empid" is set
' after the employee successfully logs in.
Dim empid As New SessionParameter()
empid.Name = "empid"
empid.Type = TypeCode.Int32
empid.SessionField = "empid"

Açıklamalar

özelliği, SessionField Web tarayıcısıyla ilişkili geçerli oturum nesnesinde depolanan bir ad/değer çiftini tanımlar. SessionField özelliği çiftin adını tanımlasa da, SessionParameter çalışma zamanında buna karşılık gelen değere bağlanır. Beklenen oturum dizesi adı/değer çifti oturumda bulunamazsa, Evaluate yöntemi parametresini ayarlanmışsa özelliğinin DefaultValue değerine bağlar. DefaultValue Özelliği ayarlanmazsa, Evaluate yöntemi parametresini bir değere bağlayamaz.

Şunlara uygulanır