I have a button that performs a postback as follows:
default.aspx
<asp:LinkButton ID="LinkButton1" CssClass="print" runat="server" PostBackUrl="Default.aspx" OnClick="ExportTaxInfoToPDF">Print</asp:LinkButton>
default.aspx.cs
protected void ExportTaxInfoToPDF(object sender, EventArgs e)
{
...
I want to pass a javascript computed value to the codebehind (such as $('#taxTable').html()
i.e. I want to bind the value of that computation to EventArgs e
so I can retrieve it on the server side) How could I go about doing that or is there a better way of achieving that?
Thank you
EDIT:
Following Tetsuya Yamamoto's suggestions, I now have the following code:
<asp:HiddenField ID="TaxTableData" runat="server" Value="" />
<asp:LinkButton ID="PrintButton" CssClass="print" runat="server" PostBackUrl="Default.aspx" OnClick="ExportTaxInfoToPDF">Print</asp:LinkButton>
TaxTableData is populated whenever the popup containing the data (in table format) is opened using directly the HTML of the table:
$("#ctl00_maincontent_TaxTableData").val($table[0].outerHTML);
The HTML is then converted into PDF using iTextSharp. It is a simple html <table>
:
<table>
<thead>
<th>...</th>
...
</thead>
<tbody>
..
I am wondering if there are better ways of transmitting the data to the server side such as not to be forced to disable security checks? Is there a way to serialize the table and unserialize it on the other side?