简体   繁体   中英

Pass generic parameter from Javascript to Asp.net C#

I am developing a jquery api get datas as LINQ list and write it as HTML table and some filter processes; Javascript, .Net C#, and Linq Used. however there is a problem I can not figure out.

I want to export filtered datas to Excel sheet. Filter created in javascript -clientside- too. So I have to send parameter from client side. On the other side, I can not use Ajax Call to export Excel. So I have to use aspx button. I search for to send parameters with Aspx Button CommandArgument attribute however it is not dynamic.

To clear, I have to send dynamic parameter to server side, and according to this params write it excel sheet returned datas.

How can I resolve this?

Easiest thing to do (I think) is to pass data through form fields either by using plain html field

// html
<input id="param1Input" name="param1" type="hidden" />
// script
document.getElementById('param1Input').value = someValue
// server code
Request.Form["param1"]

or server control

// aspx
<asp:HiddenField ID="Param1Field" runat="server" />
// script
document.getElementById('<%= Param1Field.ClientID %>').value = someValue
// server code
Param1Field.Value

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM