javascript - AJAX AsyncPostBackTrigger for MVC and .Net Application Not Updating -
i having trouble getting data update asynchronously in mvc application, have no problem same code in .net application. simple gridview linked database , want update data in gridview every few seconds without reload of entire page. works in .net application, following error in mvc:
"javascript runtime error: sys.webforms.pagerequestmanagerparsererrorexception: message received server not parsed."
the actual page static , not update. error goes away if use standard postback trigger, not want use postback trigger causes entire page reload.
<%@ page language="c#" inherits="system.web.mvc.viewpage<dynamic>" %> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>livebids</title> <script runat="server"> protected void ontimerintervalelapse(object sender, eventargs e) { gridview1.databind(); } protected void page_load(object sender, eventargs e) { currenttime.text = datetime.now.tolongtimestring(); } </script> </head> <body> <form id="form1" runat="server"> <asp:label id="currenttime" runat="server"></asp:label> <asp:scriptmanager id="scriptmanager1" runat="server"/> <asp:timer runat="server" id="ctltimer" interval="1000" ontick="ontimerintervalelapse" /> <div> <asp:updatepanel id="updatepanel1" runat="server"> <contenttemplate> <asp:gridview id="gridview1" runat="server" autogeneratecolumns="false" datasourceid="sqldatasource1"> <columns> <asp:hyperlinkfield datanavigateurlfields="item_url" datatextfield="item" target="_blank" /> <asp:boundfield datafield="bid" headertext="bid" sortexpression="bid" /> <asp:boundfield datafield="bpm" headertext="bpm" sortexpression="bpm" /> </columns> </asp:gridview> <asp:sqldatasource id="sqldatasource1" runat="server" connectionstring="<%$ connectionstrings:qbrdataconnectionstring2w %>" providername="<%$ connectionstrings:qbrdataconnectionstring2w.providername %>" selectcommand="select livebids.id, livebids.productname, max(livebids.bidprice) 'bid', count(livebids.tstamp) 'bpm', scrape1_scraped.item_url, scrape1_scraped.item livebids , scrape1_scraped livebids.id = scrape1_scraped.id , livebids.tstamp >= now() - interval 1 minute , livebids.bidprice > 0 group livebids.id order scrape1_scraped.end_time asc limit 40;"> </asp:sqldatasource> </contenttemplate> <triggers> <asp:asyncpostbacktrigger controlid="ctltimer" eventname="tick" /> </triggers> </asp:updatepanel> </div> </form> </body> </html>
this works in asp.net, mvc errors , no data update without postback.
Comments
Post a Comment