ASP.NET MVC 3 Charting and HTTPPOST -
working in asp.net mvc 3.
controller code:
[httppost] public actionresult mychart(string sdate) { /*call entity database*/ contact_center_dashboardentities3 db = new contact_center_dashboardentities3(); var results01 = db.sp_report_hybrid_metrics("9 september", sdate, "auto", "r2/r8", "claims", "claims", "r02_r08.auto.clm.fmn.q").tolist(); var chart = new chart(); chart.width = 1000; chart.height = 200; var area = new chartarea(); // configure chart area (dimensions, etc) here. chart.chartareas.add(area); area.axisx.majorgrid.enabled = false; area.axisy.majorgrid.enabled = false; area.axisy2.majorgrid.enabled = false; area.axisy2.labelstyle.format = "0%"; // create , customize info series. var series = new series(); foreach (var item in results01) { series.points.addxy(item.date, item.volume); } series.font = new font("segoe ui", 8.0f, fontstyle.bold); series.charttype = seriescharttype.column; series.yaxistype = axistype.primary; // create , customize info series. var seriessecondary = new series(); foreach (var item in results01) { seriessecondary.points.addxy(item.date, item.xferper); } seriessecondary.font = new font("segoe ui", 8.0f, fontstyle.bold); seriessecondary.charttype = seriescharttype.line; seriessecondary.yaxistype = axistype.secondary; seriessecondary.labelformat = "0%"; seriessecondary.isvalueshownaslabel = true; chart.series.add(series); chart.series.add(seriessecondary); var returnstream = new memorystream(); chart.imagetype = chartimagetype.png; chart.saveimage(returnstream); returnstream.position = 0; homecoming new filestreamresult(returnstream, "image/png"); }
tables view code:
@using (html.beginform("mychart", "home", formmethod.post)) { <fieldset> <div class="editor-field"> <input type="submit" value="09/06/2014" name = "sdate"/> </div> </fieldset> }
when user clicks submit button, value passes "mychart" actionresult correctly, takes me mychart view. need pass value through, remain on tables view, , refresh chart.
you seek this:
@using (ajax.beginform("mychart", "home", new ajaxoptions{httpmethod= "post", updatetargetid = "chartcontainer", insertionmode = insertionmode.replace})) { <fieldset> <div class="editor-field"> <input type="submit" value="09/06/2014" name = "sdate"/> </div> </fieldset> } <div id="chartcontainer"> </div>
the request done ajax , inserts response of request element addressed updatetargetid. if submit button should deleted after clicking once, place form within div. otherwise chart refreshed overtime press submit-button.
asp.net asp.net-mvc-3
No comments:
Post a Comment