我有一個單行代碼,現在顯示JS警報。我試圖用jQuery警報替換它,以便我可以將其設置爲主題。下面是我寫的jQuery的警報代碼:在Asp.net中使用ScriptManager調用jquery警報
ScriptManager.RegisterStartupScript(this, GetType(), "onload",
"window.onload = function() {jAlert('This is a custom alert box', 'Alert Dialog');}", true);
該代碼曾經是這樣的:
ScriptManager.RegisterStartupScript(this, GetType(), "showalert",
"alert('This is a custom alert box');", true);
現有的代碼工作正常。但我的代碼給我一個錯誤的說法,
value of property jalert is null
我不確定,我很想念這裏。
是jquery.js和加載到瀏覽器在onload函數觸發時? –
我這麼認爲。不知道我該如何檢查它是否是。我應該改變onload到別的東西嗎? – jitendragarg
你應該檢查這個http://stackoverflow.com/questions/4760207/asp-net-clientscript-registerclientscriptblock-fires-before-jquery-is-loaded –