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 アプリケーション内のリソース
リソースのパッケージ化と配置



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「TemplateControl.GetLocalResourceObject」の関連用語

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

   

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



TemplateControl.GetLocalResourceObjectのページの著作権

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

©2026 GRAS Group, Inc.RSS