views:

1254

answers:

6

Hi,

I wanna add server controls by using javascript. The main purpose of why I want is to add controls without any postback and get them in code-behind.

A: 

That is not generally possible. You must add server side controls on the server.

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

Strelok
A: 

hmm thanks...

BUT, If I have a clint side controls and how can i get their values from code-behind.

e.g.

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

I wanna get the control,above, value from code behind in asp.net.

Thanks in advance.

Braveyard
A: 

Some one please can give me some answers ? :(

Braveyard
+2  A: 

Try to access the html inputs with Request.Form

Request.Form["inputName"]

You will have to set the name attribute on your inputs like this:

<input type="text" value="blah" name="inputName" />
CMS
Thanks but I guess I can't choose 2 answers as an answer ?
Braveyard
+4  A: 

You can check the Request.Form collection for all form values (client side controls) on the server. Each control will need to have a unique ID 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 would access the value as Request.Form["testBox"].

Yobi21
Thanks,It really helps :)
Braveyard
+1  A: 

if its a form post you can get the value with request.form["control"] one of the properties will help you do it, if its a new control in some page you can do something with ajax , i did not try it, its just a theory,

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

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

but its a bit of an hack to me..

Moran