Adding Controls dynamically and retrieving data at Server-Side [Resolved]

Posted by Learningtorise under ASP.NET on 8/6/2013 | Points: 10 | Views : 6647 | Status : [Member] | Replies : 5
Hi Guys,

My new application demands that based on "Process" selection, controls on my page should be changed/created.

Suppose when i select "Process A", a textbox and a radiobutton should appear. Whereas, if i select "Process B", a dropdown and a textbox should appear.

How can i achieve this? What would be best practice? Also If i use Jquery to create a element dynamically, how can i retrieve its value on Server-Side?

Thank You in advance

http://hashtagakash.wordpress.com/


Responses

Posted by: Bhupentiwari on: 8/6/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved
refer below link it will help you

if you now claasic asp just recall it is very easy

msdn.microsoft.com/en-us/library/ms525985(v=vs.90).aspx
http://stackoverflow.com/questions/6159103/how-can-i-get-all-element-values-from-request-form-without-specifying-exactly-wh

Thanks n Regards
Bhupendra Tiwari

Learningtorise, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 8/6/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Dear Akash,
The best solution is you need to place all your control on page. Depending on the condition visible appropriate control on page.
This will reduce your code and solve you problem.
Hope this will help you.

Learningtorise, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Learningtorise on: 8/6/2013 [Member] Starter | Points: 25

Up
0
Down
Hey Mahesh!
Glad to see your reply.
I thought of this too.
But this is last thing i'm gonna try/adopt because of following reasons:
1> My Number of Controls will be dynamic. That is, in future maybe there will be need of adding few more controls on page.
2> Also, in my requirement there will be about 30-40 different input controls for each Process.
So, my code will not reduce but become cumbersome!


http://hashtagakash.wordpress.com/

Learningtorise, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rimi1289 on: 8/6/2013 [Member] Starter | Points: 25

Up
0
Down
This link will help. It shows how to dynamically add and remove html elements (what it means is elements like "textbox" etc) using JQuery. All you have to do is, add "runat=server " with the "textbox" elements. This is will allow the server side (code behind) script to read the values in the textboxes. Also you can add any number of elements dynamically.

http://www.encodedna.com/2013/07/dynamically-add-remove-textbox-control-using-jquery.htm

Learningtorise, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Learningtorise on: 8/7/2013 [Member] Starter | Points: 25

Up
0
Down
Thanks guys!
Let me try both and i let you know whether its working for me or not!

By the way, Rimi,
Even if i append a textbox in my HTML Page using JQuery, but how can i get TextBox's Value in Code-Behind?
Because after appending a TextBox control in page, when i do "View Source Code", i am unable to see Textbox in HTML Code and hence unable to get its Value at Code Behind page(*.cs).

http://hashtagakash.wordpress.com/

Learningtorise, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response