0

i'm working in a webform page and i want to pass data from the "Client-Side" (ASPX) a value returned by jquery event to the "code behind" (ASPX.CS).

Thanks.

Mr. Newbie
  • 382
  • 5
  • 17
  • You can use `Request("varName")` ... – Hackerman Jun 19 '14 at 16:16
  • 1
    Your notion that ASPX is the client is misleading. ASPX files are processed on the server, the result markup is HTML and sent to the client. Instead of asking how to pass data from ASPX to ASPX.CS, you should say "how can I pass data from the client side to the code behind?" – mason Jun 19 '14 at 16:23
  • if you are not planning to use any server side controls when u post the data back to aspx.cs file you can consider using PageMethods – Karthik Ganesan Jun 19 '14 at 16:35

2 Answers2

1

You can save the value in a hidden field and access to it from the server:

or

Set value of hidden field in a form using jQuery's ".val()" doesn't work

Community
  • 1
  • 1
Karina
  • 71
  • 3
0

Just set the value to an input field like normal. When the page posts to the code behind, the value will be resident.

Example

HTML Markup:

<asp:Textbox id="myTextbox" runat="server" ClientIDMode="Static"/>

jQuery:

$('#myTextbox').val('myVal');

Again, when the form is posted, the value will be sent..

ewitkows
  • 3,528
  • 3
  • 40
  • 62