TemplateControl.GetLocalResourceObject メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > TemplateControl.GetLocalResourceObject メソッドの意味・解説 

TemplateControl.GetLocalResourceObject メソッド (String)

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

ページ レベル リソース オブジェクトを、指定されResourceKey プロパティ基づいて取得します

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)
構文構文

Protected Function GetLocalResourceObject (
 _
    resourceKey As String _
) As Object
Dim resourceKey As String
Dim returnValue As Object

returnValue = Me.GetLocalResourceObject(resourceKey)
protected Object GetLocalResourceObject (
    string resourceKey
)
protected:
Object^ GetLocalResourceObject (
    String^ resourceKey
)
protected Object GetLocalResourceObject (
    String resourceKey
)
protected function GetLocalResourceObject (
    resourceKey : String
) : Object

パラメータ

resourceKey

ResourceKey を表す文字列。

戻り値
要求されリソース オブジェクトを表すオブジェクトそれ以外場合null 参照 (Visual Basic では Nothing)。

解説解説
使用例使用例

GetLocalResourceObject メソッド使用して、App_LocalResources フォルダ内のローカル ページ リソースから LocalResourceString1 という名前の文字列アクセスする方法次のコード例示します

<%@ Page Language="VB" Culture="auto"
 UICulture="auto" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  Protected Sub Page_Load(ByVal
 sender As Object, ByVal
 e As System.EventArgs)

    Dim localresourcestring As String
    Dim globalresourcestring As String
    
    ' Get the local resource string.
    Try

      localresourcestring = "Found the local resource string
 and it's value is: " & _
        Convert.ToString(GetLocalResourceObject("LocalResourceString1"))
 & "."
      
    Catch
    
      localresourcestring = "Could not find local resource."

    End Try
    
    ' Get the global resource string.
    Try

      ' Look in the global resource file called MyResource.resx.
      globalresourcestring = "Found the global resource string
 and it's value is: " & _
        Convert.ToString(GetGlobalResourceObject("MyResource",
 "GlobalResourceString1")) & "."

    Catch

      globalresourcestring = "Could not find global resource."

    End Try

    LocalResourceMessage.InnerText = localresourcestring
    GlobalResourceMessage.InnerText = globalresourcestring

  End Sub
</script>

<html  >
<head id="Head1" runat="server">
    <title>TemplateControl GetGlobalResourceObject and GetLocalResourceObject
 Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <h3>TemplateControl GetGlobalResourceObject and GetLocalResourceObject
 Example</h3>
      <span id="LocalResourceMessage"
            runat="server"/>
      <br />
      <span id="GlobalResourceMessage"
            runat="server" />
    </div>
    </form>
</body>
</html>
<%@ Page Language="C#" Culture="auto" UICulture="auto"
 %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  protected void Page_Load(object sender, EventArgs
 e)
  {
    string localresourcestring;
    string globalresourcestring;
    
    // Get the local resource string.
    try
    {
      localresourcestring = "Found the local resource string
 and it's value is: " + 
        (String)GetLocalResourceObject("LocalResourceString1") + ".";
    }
    catch
    {
      localresourcestring = "Could not find local resource.";
    }
    
    // Get the global resource string.
    try
    {
      // Look in the global resource file called MyResource.resx.
      globalresourcestring = "Found the global resource string
 and it's value is: " +
        (String)GetGlobalResourceObject("MyResource", "GlobalResourceString1")
 + ".";
    }
    catch
    {
      globalresourcestring = "Could not find global resource.";
    }

    LocalResourceMessage.InnerText = localresourcestring;
    GlobalResourceMessage.InnerText = globalresourcestring;

  }
</script>

<html  >
<head runat="server">
    <title>TemplateControl GetGlobalResourceObject and GetLocalResourceObject
 Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <h3>TemplateControl GetGlobalResourceObject and GetLocalResourceObject
 Example</h3>
      <span id="LocalResourceMessage"
            runat="server"/>
      <br />
      <span id="GlobalResourceMessage"
            runat="server" />
    </div>
    </form>
</body>
</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

TemplateControl.GetLocalResourceObject メソッド (String, Type, String)

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

ページ レベル リソース オブジェクトを、指定されResourceKey プロパティオブジェクト型、およびプロパティ名に基づいて取得します

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)
構文構文

Protected Function GetLocalResourceObject (
 _
    resourceKey As String, _
    objType As Type, _
    propName As String _
) As Object
Dim resourceKey As String
Dim objType As Type
Dim propName As String
Dim returnValue As Object

returnValue = Me.GetLocalResourceObject(resourceKey, objType,
 propName)
protected Object GetLocalResourceObject (
    string resourceKey,
    Type objType,
    string propName
)
protected:
Object^ GetLocalResourceObject (
    String^ resourceKey, 
    Type^ objType, 
    String^ propName
)
protected Object GetLocalResourceObject (
    String resourceKey, 
    Type objType, 
    String propName
)
protected function GetLocalResourceObject (
    resourceKey : String, 
    objType : Type, 
    propName : String
) : Object

パラメータ

resourceKey

ResourceKey を表す文字列。

objType

取得するリソース オブジェクトの型。

propName

取得するリソース オブジェクトプロパティ名。

戻り値
要求されリソース オブジェクトを表すオブジェクトそれ以外場合null 参照 (Visual Basic では Nothing)。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

TemplateControl.GetLocalResourceObject メソッド

ページ レベル リソース取得します
オーバーロードの一覧オーバーロードの一覧

名前 説明
TemplateControl.GetLocalResourceObject (String) ページ レベル リソース オブジェクトを、指定された ResourceKey プロパティ基づいて取得します
TemplateControl.GetLocalResourceObject (String, Type, String) ページ レベル リソース オブジェクトを、指定されResourceKey プロパティオブジェクト型、およびプロパティ名に基づいて取得します
参照参照

関連項目

TemplateControl クラス
TemplateControl メンバ
System.Web.UI 名前空間
ResourceExpressionBuilder

その他の技術情報

ASP.NET アプリケーション内のリソース
リソースパッケージ化配置



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

TemplateControl.GetLocalResourceObject メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



TemplateControl.GetLocalResourceObject メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS