我想在用戶按下功能鍵時打開html頁面。如何從主頁面調用Webservice功能
現在功能鍵的捕獲工作正常,但打開相應頁面的邏輯寫在母版頁的代碼後面。
我在互聯網上看到,如果我想在代碼背後調用函數,那麼我必須創建一個web服務並從母版頁調用webservice方法。
但由於某種原因,這是行不通的。可能是我沒有正確調用Web服務。
可以請一些身體幫忙嗎?
非常感謝
<cc1:ToolkitScriptManager ID="ScriptManager1" runat="server" ScriptMode="Release" EnableHistory="true" EnableSecureHistoryState="false"
EnablePageMethods="true" CombineScripts="false">
<Scripts>
<asp:ScriptReference Path="~/ShowHelpPage.asmx" />
</Scripts>
</cc1:ToolkitScriptManager>
document.onkeydown = function(event){
if(window.event && window.event.keyCode == 113)
{
window.open("HelpFile/index.html");
}
else if(event.which == 113)
{
window.open("HelpFile/index.html");
DisplayHelpFile();
}
}
function DisplayHelpFile()
{
var i = PageMethods.DisplayHelpPage();// I think this is wrong
alert(i);
}
Web方法
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class ShowHelpPage : System.Web.Services.WebService
{
[WebMethod]
public string DisplayHelpPage()
{
return "Window.Html";
}
}
感謝您的幫助。 – Vin05
很高興幫助! – Jonathan