In IE, when I call a page method from the OnPaste event, I get the following error when I click on the input box and hit CTRL+V:
0x80070057 - JavaScript runtime error: Invalid argument.
at this line of code:
this._xmlHttpRequest.open(verb, this._webRequest.getResolvedUrl(), true );
The call stack looks like this:
Sys$Net$XMLHttpExecutor$executeRequest [ScriptResource.axd] Line 6055 Script
Sys$Net$_WebRequestManager$executeRequest [ScriptResource.axd] Line 6302 Script
Sys$Net$WebRequest$invoke [ScriptResource.axd] Line 6481 Script
Sys$Net$WebServiceProxy$invoke [ScriptResource.axd] Line 6923 Script
Sys$Net$WebServiceProxy$_invoke [ScriptResource.axd] Line 6807 Script
PageMethods.prototype.Message [WebForm1.aspx] Line 76 Script
PageMethods.Message [WebForm1.aspx] Line 117 Script
GetMessage [WebForm1.aspx] Line 11 Script
onpaste [WebForm1.aspx] Line 125 Script
I've reproduced it in a small project. Here's WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="PageMethodTest.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type='text/javascript'>
function GetMessage() {
PageMethods.Message(OnGetMessageSuccess, OnGetMessageFailure);
}
function OnGetMessageSuccess(result, userContext, methodName) {
alert(result);
}
function OnGetMessageFailure(error, userContext, methodName) {
alert(error.get_message());
}
</script>
</head>
<body>
<form id='form1' runat='server'>
<input value="paste here" onpaste="GetMessage()" onblur="GetMessage()" />
<asp:ScriptManager ID='ScriptManager1' runat='server' EnablePageMethods='true' />
<div>
<input type='submit' value='Get Message' onclick='GetMessage(); return false;' />
</div>
</form>
</body>
</html>
Here's WebForm1.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace PageMethodTest
{
public partial class WebForm1 : System.Web.UI.Page
{
[System.Web.Services.WebMethod]
public static string Message()
{
return "Hello from the server-side World!";
}
}
}
I've called the same Page Method from the OnBlur event and when you tab out of the input box, it works fine. This OnPaste event calling PageMethod works fine in Chrome. Is there some difference in the context of an OnPaste event for IE vs most other events?
Thanks.