共用方式為


ScriptResourceAttribute.ScriptResourceName 屬性

定義

警告

This property is obsolete. Use StringResourceName instead.

取得指令碼程式庫之資源檔的名稱。

public:
 property System::String ^ ScriptResourceName { System::String ^ get(); };
public string ScriptResourceName { get; }
[System.Obsolete("This property is obsolete. Use StringResourceName instead.")]
public string ScriptResourceName { get; }
member this.ScriptResourceName : string
[<System.Obsolete("This property is obsolete. Use StringResourceName instead.")>]
member this.ScriptResourceName : string
Public ReadOnly Property ScriptResourceName As String

屬性值

String

指令碼程式庫之資源檔的名稱。

屬性

範例

下列範例顯示 ScriptResourceAttribute 名為 CheckAnswer.js 腳本檔案的屬性,該檔案使用來自 AuthenticationResources 資源檔的資源。 名稱 Answer 是用來參考這些資源。 在此範例中 ScriptResourceName ,屬性會傳回 「LocalizingResources.VerificationResources」。 當您定義 ScriptResourceName 時,不包含副檔名。

[assembly: System.Web.UI.WebResource("LocalizingScriptResources.CheckAnswer.js", "application/x-javascript")]
[assembly: System.Web.UI.ScriptResource("LocalizingScriptResources.CheckAnswer.js", "LocalizingScriptResources.VerificationResources", "Answer")]
<Assembly: System.Web.UI.WebResource("LocalizingScriptResources.CheckAnswer.js", "application/x-javascript")> 
<Assembly: System.Web.UI.ScriptResource("LocalizingScriptResources.CheckAnswer.js", "LocalizingScriptResources.VerificationResources", "Answer")>

下列範例示範如何在用戶端腳本中使用資源。 資源索引鍵 (CorrectIncorrect) 前面會加上 Answer ,以識別包含值的腳本資源定義。

function CheckAnswer()
{
    var firstInt = $get('firstNumber').innerText;
    var secondInt = $get('secondNumber').innerText;
    var userAnswer = $get('userAnswer');
    
    if ((Number.parseLocale(firstInt) + Number.parseLocale(secondInt)) == userAnswer.value)
    {
        alert(Answer.Correct);
        return true;
    }
    else
    {
        alert(Answer.Incorrect);
        return false;
    }
}

適用於