Adding controls with Javascript and getting their value from codebehind

I want to add server controls using javascript. The main purpose why I want is to add non postback controls and get them encoded.

+1


source to share


4 answers


You can check the Request.Form collection for all form values ​​(client side controls) on the server. Each control must have a unique identifier to access it in the request.Form collection.

For example, if you had the following control



<input type="text" id="testBox" value="blah" />

      

On the server, you will access the value as Request.Form ["testBox"].

+4


source


Try to access html inputs with Request.Form

Request.Form["inputName"]

      



You need to set the attribute name

on your inputs like this:

<input type="text" value="blah" name="inputName" />

      

+2


source


If it's a form post, you can get the value with request.form ["control"], one of the properties will help you do that, if its a new control on some page you can do something with ajax, I haven't tried his, his just a theory,

you can make an ajax request that will create a textboox control on the server and then display the html on your page.

now when you call text1.text you will get the value.

but its a bit of a hack to me.

+1


source


This is not possible at all. You have to add server controls on the server.

If you want to avoid the visibility of postbacks, use AJAX and UpdatePanel. Otherwise, you're out of luck.

0


source







All Articles