How to use the value of an HTML field within code Behind C#?

Asked

Viewed 556 times

1

I have a Javascript code that creates HTML fields on an Asp.net page. How do you call the function to the Code Behind and return to the created fields? If I could use ASP.NET in this case, I would have to create several Textbox and manipulate the value on the server.

<input type="text" onblur="pesquisa(this.name, 1)" maxlength="10" size="10" value="" name="contrato1" onkeypress="FiltraTecla(event);">
  • Have you thought about using jQuery+Ajax?

  • Actually to pick up the content I must give a request within the page, but my problem is how I call the search function that is within the codebehide

  • Precisely, with Ajax you must achieve your goal. (:

  • You could post an example?

  • What exactly you need to create?

  • @Ciganomorrisonmendez I’ve already created a series of textbox inputs via javascript. I need to retrieve the typed information inside the codebehide and then return the result to the rest of the components.

Show 1 more comment

1 answer

1


Inform a name for the element, and then in code-Behind use Request.Form["nomeDoElemento"] to obtain it.

For example, if Javascript code creates an element

<input type="text" name="nomeDoCliente" />

the value of this field can be obtained in code-Behind as follows:

string cliente = Request.Form["nomeDoCliente"];
  • It worked, now the problem is that my input type='textbox' is not changing the value when exiting javascript.

  • The input should be changed to some specific value?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.