I am currently adding keyboard shortcuts to our web appl开发者_开发百科ication, so from JavaScript.
So far, it has consisted mostly in triggering the click events of buttons already exposed in the user-interface.
Now, I would like to add another one which redirects to another page. The new page URL needs to be generated based on elements from the source page query string. Basically, I have a date in the query string and I want to generate a new URL for the next day.
I feel that it would be easier to do it server-side, using the DateTime methods and then Response.Redirect than simply using JavaScript.
I've tried decorating a method using and then calling it from the Javascript. However, for WebMethods to work, I need to enable EnablePageMethods to true on the ScriptManager and when I do that, I am getting errors like this. The ScriptManager currently is in the master page, so its feature is automatically inherited to all contents pages as well.
It basically looks like this:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True" EnablePageMethods="True"></asp:ScriptManager>
When I add the EnablePageMethods attribute, and then run the application, I get this ASP.Net error:
Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Required attribute 'name' not found.
Source Error:
<jsonSerialization maxJsonLength="500">
<converters>
<add type="Microsoft.Web.Script.Serialization.Converters.DataSetConverter"/>
<add type="Microsoft.Web.Script.Serialization.Converters.DataRowConverter"/>
<add type="Microsoft.Web.Script.Serialization.Converters.DataTableConverter"/>
I am not sure what I need to do to solve this error, so I would need to either find a way to fix this or find a workaround to execute my server-side method without relying on EnablePageMethods. I am thinking about adding an invisible button to the webpage and simulating a click to it to execute my server-side method, but that looks like a relatively unclean workaround.
Can somebody please help / give some pointers? I am using ASP.Net in VB 2005 in NET 2.0.
Thanks in advance.
You need to give those converters names, because that's a required attribute on <add />
, e.g.;
<add type="Microsoft.Web.Script.Serialization.Converters.DataSetConverter"
name="DataSetConverter" />
<add type="Microsoft.Web.Script.Serialization.Converters.DataRowConverter"
name="DataRowConverter" />
<add type="Microsoft.Web.Script.Serialization.Converters.DataTableConverter"
name="DataTableConverter" />
精彩评论