SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to dynamically add controls to a webpart without having a postback for example with AJAX/Java Script/jQuery/Partial Postback within SharePoint? I'm searching for some kind of possibility/best practice.

The controls I'm talking about are dropdownlists/labels/textboxes.

Extra details: I'm developing a webpart for SP2010 (farm solution).

share|improve this question
Have you tried using <asp:UpdatePanel>? – Daniel Ziga Jan 4 '12 at 12:34
So basically if I understand this UpdatePanel I can add any control to the panel with a trigger that is standing outside of the UpdatePanel? – OG_Mike Jan 4 '12 at 12:57
up vote 3 down vote accepted

A webpart is a just a kind of control, nothing specific to SharePoint considering what you want to achieve.You can use javascript\jquery\ajax to add controls dynamically.

With javascript\jquery, you can add HTML controls.Check this :

With Ajax Updatepanel, you can add server side controls. Check this :

share|improve this answer
Ok so I managed to get the UpdatePanel kind of working. But I'm facing another problem here. I want to the controls to be added to my UpdatePanel after a button click event. This works fine although the previously entered data/values in the previously added controls go away after the click event. How can I fix this, do I need to trigger a postback event? If yes I tried to add a PostBackTrigger but I'm not able to have it working. – OG_Mike Jan 5 '12 at 12:57

You can use jquery Ajax pretty easily and either have the response return some more html which you can add to an element on the page or build elements based on data returned.

The update panel is a simple way to implement ajax in ASP.NET but may be (depends on req) more difficult to add controls dynamically (you may end up using JS anyway.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.