TemplateControl.GetGlobalResourceObjectとは? わかりやすく解説

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

TemplateControl.GetGlobalResourceObject メソッド (String, String)

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

アプリケーション レベル リソース オブジェクトを、指定した ClassKey プロパティおよび ResourceKey プロパティ基づいて取得します

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

Protected Function GetGlobalResourceObject
 ( _
    className As String, _
    resourceKey As String _
) As Object
Dim className As String
Dim resourceKey As String
Dim returnValue As Object

returnValue = Me.GetGlobalResourceObject(className, resourceKey)
protected Object GetGlobalResourceObject (
    string className,
    string resourceKey
)
protected:
Object^ GetGlobalResourceObject (
    String^ className, 
    String^ resourceKey
)
protected Object GetGlobalResourceObject (
    String className, 
    String resourceKey
)
protected function GetGlobalResourceObject
 (
    className : String, 
    resourceKey : String
) : Object

パラメータ

className

ClassKey を表す文字列。

resourceKey

ResourceKey を表す文字列。

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

解説解説
使用例使用例

GetGlobalResourceObject メソッド使用して、App_GlobalResources フォルダ内の MyResource.resx という名前のグローバル リソースから GlobalResourceString1 という名前の文字列アクセスする方法次のコード例示しますclassName パラメータが .resx 拡張子なしの MyResourceなります

<%@ 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.GetGlobalResourceObject メソッド (String, String, Type, String)

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

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

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

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

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

パラメータ

className

ClassKey を表す文字列。

resourceKey

ResourceKey を表す文字列。

objType

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

propName

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

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

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

TemplateControl.GetGlobalResourceObject メソッド




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

辞書ショートカット

すべての辞書の索引

「TemplateControl.GetGlobalResourceObject」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS