c# - how to call a .aspx file in a .ascx file with json/ajax -
I am currently trying to create a very large website, which is ASP.N Currently I'm working on a bit where the user presses a button and some special text is shown (this explanation is described to make it relatively simple). I have to show in a small block on the site. I want to use AJAX / json to call the Axx file The .aspx file has its own method that produces output, so I need all. To call the .xx file aspx file, maybe specify that method and pass the parameter
I will post my code below, can someone please take a look? Please tell me whether I forgot something important or something is not clear. Although I am not a supporter at this
PollDetail.ascx
& lt; Script src = "// cdn.jsdelivr.net/excanvas/r3/excanvas.js" type = "text / javascript" & gt; & Lt; / Script & gt; & Lt; Script src = "// cdn.jsdelivr.net/chart.js/0.2/Chart.js" type = "text / javascript" & gt; & Lt; / Script & gt; & Lt; Div runat = "server" id = "form1" & gt; & Lt; Script type = "text / javascript" & gt; $ (Function () {loadchart (); $ ("[id * = ddlCountries]"). Tie ("change", function () {loadchirt ();})}}); Function Load Chart () {Var Chart Type = Perseverant ($ ("[id * = rblChartType] Input: Checked"). Val ()); $ .ajax ({type: "POST", url: "PollGrafiek.aspx / GetChart", //PollDetail.ascx/GetChart Data: "{pollID: '" + $ ("getPollID") + "'}", / "Jason", Success: Work (R) {$ ("$"), "Jason" $ Dvchart "" .HTML (""); $ ("# dvLegend") .HTML (""); var data = eval (rd); var el = document.create element ('canvas'); $ ("# Dvchart ") [0] .appendChild (el); // Fix for IE 8 ($ .browser.msie & amp; $ .browser.version ==" 8.0 ") {G_vmlCanvasManager.initElement (el);} var ctx = El .getContext ('2d'); var User StrenthSchurch = New Chart (CTX) .pie (data); for (var i = 0; i & lt; data Lamps; i ++) {var div = $ ("& lt; div / & gt;"); DivCss ("margin-down", "10px"); div.html ("& lt; span style = 'Display: Inline-Block; Height: 10px; Width: 10px; Background-Color: "+ Data [i] .color +"' & gt; & lt; / span & gt; "+ Data [i] .text ); $ ("# DvLegend"). Attachment (div);}}, failure: function (response) {alert ('an error occurred.'); }}); } & Lt; / Script & gt; & Lt; / Div & gt; PollGrafiek.aspx
& lt;% @page language = "C #" AutoEventWireup = "true" CodeFile = "PollGrafiek.aspx.cs" Inherited = "polygraphic"%> & Lt ;; DOCTYPE HTML PUBLIC "- // W3C // DTT XHTML 1.0 Transcription // N" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> & Lt; Html xmlns = "http://www.w3.org/1999/xhtml" & gt; & Lt; Head runat = "server" & gt; & Lt; Title & gt; & Lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Script type = "text / javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Script src = "// cdn.jsdelivr.net/excanvas/r3/excanvas.js" type = "text / javascript" & gt; & Lt; / Script & gt; & Lt; Script src = "// cdn.jsdelivr.net/chart.js/0.2/Chart.js" type = "text / javascript" & gt; & Lt; / Script & gt; & Lt; Div runat = "server" id = "form1" & gt; & Lt; Script type = "text / javascript" & gt; & Lt; / Script & gt; & Lt; Table range = "0" cell padding = "0" cell area = "0" & gt; & Lt; TR & gt; & Lt; TD & gt; Country: & lt; Asp: dropdown list id = "ddlCountries" runat = "server" & gt; & Lt; Asp: ListItem text = "USA" value = "USA" /> & Lt; Asp: ListItem text = "Brazil" value = "Brazil" /> & Lt; / ASP: DropDownList & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; Div id = "dwChart" & gt; & Lt; / Div & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; Div id = "dvLegend" & gt; & Lt; / Div & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt; PollGrafiek.aspx.cs Public Partial PollGrafiek: System.Web.UI.Page {[WebMethod] Public Static String GetChart (integer pollID) } "itemprop =" text "> after you
I think the URL you want
Comments
Post a Comment