Search results
16 sty 2012 · You could send it as a JSON string. Here's an example using jQuery: var array = [ 'foo', 'bar', 'baz' ]; $.ajax({ url: '/foo.aspx/SaveView', type: 'POST', contentType: 'application/json', data: JSON.stringify({ myArray: array }), success: function(result) { } });
7 lut 2011 · Just make sure you have an input control like a hidden field marked with the runat="server" and set the value of the control to the result of a .join(',') of your JS array. You can probably do this with the javascript function that created the array in the first place.
In the call to DotNet.invokeMethodAsync (server-side or client-side components) or DotNet.invokeMethod (client-side components only), call DifferentMethodName to execute the ReturnArrayAsync .NET method: DotNet.invokeMethodAsync('BlazorSample', 'DifferentMethodName');
To pass data from JavaScript to the C# code is by setting hidden ASP variables and triggering a postback: <asp:HiddenField ID="RandomList" runat="server" /> function SetDataField(data) { document.getElementById('<%=RandomList.ClientID%>').value = data; }
The example demonstrates how to invoke a JS function from a C# method that offloads a requirement from developer code to an existing JS API. The JS function accepts a byte array from a C# method, decodes the array, and returns the text to the component for display. HTML.
1 wrz 2018 · When passing parameters from C# to JavaScript, you must put the parameters in an array. In my C# Blazor code, for example, I can pass multiple parameters to the JavaScript function with code like this: JSRuntime.Current.InvokeAsync<object>("SayHelloJS", new object[] { wrappedCust, "Peter"});
The following example demonstrates the ToArray method and other methods of the List<T> class that act on ranges. At the end of the example, the GetRange method is used to get three items from the list, beginning with index location 2.