Click here to Skip to main content


QuestionControls are not displayed on using Asp:AsyncPostBackTrigger [modified] PinmemberShashank Srivastava1)3-Oct-12 21:38 
I am creating Ajax Draggable panels on Onclick event of a button but I'm facing problem while making the use of asp:AsyncPostBackTrigger viz.

1)When I use asp:AsyncPostBackTrigger control is created and retains its position but further on click event of button(aspx) newly created controls are not displayed but while debugging it shows that new controls(usercontrol) are being created.

2)If I don't use asp:AsyncPostBackTrigger then on every click of the Button(on <b>aspx</b> page) control(<b>usercontrol</b>) is being created and is also draggable but they are not retaining their positions.

<b>I'm doing all this stuff on the web form</b>

--<b>aspx page</b>--
      <cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnablePartialRendering="true" ></cc1:ToolkitScriptManager>
      <asp:Button ID="btn" runat="server" Text="Add" OnClick="btnAdd_OnClick" />
      <asp:Panel ID="pnl_wrapper" runat="server"></asp:Panel>

   Dictionary<string, string> myControlList;
      protected void Page_Load(object sender, EventArgs e)

      protected override void OnInit(EventArgs e)

         if (!IsPostBack)
            myControlList = new Dictionary<string, string>();
            Session["myControlList"] = myControlList;
            myControlList = (Dictionary<string, string>)Session["myControlList"];

            foreach (var registeredControlID in myControlList.Keys)
               UserControl controlToAdd = new UserControl();
               controlToAdd = (UserControl)controlToAdd.LoadControl(myControlList[registeredControlID]);
               controlToAdd.ID = registeredControlID;

      protected void btnAdd_OnClick(object sender, EventArgs e)
         UserControl controlToAdd = new UserControl();
         controlToAdd = (UserControl)controlToAdd.LoadControl("ufinal.ascx");

         controlToAdd.ID = Guid.NewGuid().ToString();
         myControlList.Add(controlToAdd.ID,   controlToAdd.AppRelativeVirtualPath);

<asp:UpdatePanel runat="server" UpdateMode="Conditional">
      <cc1:DragPanelExtender runat="server" TargetControlID="PnlContainer"
         <asp:Panel ID="PnlContainer" runat="server" CssClass="dragContainer">
            <asp:Panel ID="PnlHeader" runat="server" CssClass="dragHeader">
               Click and Drag Here
            <asp:Panel ID="PnlDetail" runat="server" CssClass="dragDetail">
               My name is Shashank<br />
      <asp:AsyncPostBackTrigger ControlID="btn" />

&lt;script type="text/javascript">
   function setBodyHeightToContentHeight() { = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight) + "px";

-- modified 4-Oct-12 4:28am.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Advertise | Privacy | Mobile
Web04 | 2.8.150331.1 | Last Updated 1 Apr 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid