Update panel from custom control

Last post 08-27-2008 3:04 PM by atanu.podder. 2 replies.

Sort Posts:

  • Update panel from custom control

    08-27-2008, 12:42 PM

    Web web app looks similar to a file explorer - on the left is a tree heriarchy and on the right is a content pane.

    At the moment I have it framed, with the tree on the left, and the content on the right. However I want to be able to produce the same effect with update panels.

    The trouble is, I don't know how to trigger the panel to update from the custom control on the left (and pass a parameter to it, so that it updates with the right content).

    My custom control is basically a jQuery file tree which sends down pieces of html to the client.

     

    (p.s. the tag selector on this forum is pretty broken, it appears tags are separated by commas, yet pressing space triggers the autocomplete- is that gonna be fixed any time?) 

  • Re: Update panel from custom control

    08-27-2008, 2:18 PM
    Answer

    If your custom control throws an event, you can add an async postback trigger to your update panel pointing to the custom control.  Here's the documention on it:

    http://msdn.microsoft.com/en-us/library/system.web.ui.asyncpostbacktrigger.aspx

    If you just want to do the postback using client script, this is also possible.  Here's a quick sample of making it work (you just need to call doPostBack with the update panel you want to update as the first param, and the argument you want to pass as the second):

    <asp:ScriptManager ID="ScriptManager1" runat="server">

    </asp:ScriptManager>

    <script runat="server">

    protected void Page_Load(object sender, EventArgs e)

    {

    if (IsPostBack)

    {

    this.TextBox1.Text = Page.Request.Params["__EVENTARGUMENT"].ToString();

    }

    }

    </script>

    <div>

    <table>

    <tr>

    <td>

    <input id="Button1" type="button" value="button"

    onclick="__doPostBack('<%=UpdatePanel1.ClientID %>','somevalue')" />

    <td>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">

    <ContentTemplate>

    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

    </ContentTemplate>

    </asp:UpdatePanel>

    </td>

    </tr>

    </table>

    </div>

    James

    James Ashley, Magenic Technologies
    (james.ashley.magenic@gmail.com)
  • Re: Update panel from custom control

    08-27-2008, 3:04 PM
    Answer
    • Participant
      1,274 point Participant
    • atanu.podder
    • Member since 08-20-2008, 7:40 AM
    • Bangalore
    • Posts 191

    You can achieve this with out triggers.

    1. Place two update panels, say up1 and up2, set both these update panel's update mode top conditional

    2. In up1, place a treeview, and in up2 place a panel.

    3. Register for treeview's onSelectedNodeChanged event.

    4. In that  onSelectedNodeChanged event, you would able to access the treenode crrently slcted, take that node and retrive the information that you need to display into up2

    5. Set appropriate control values in the up2

    6. Invoke update() methd on up2.

    Thats it!

    Thanks,

    Atanu
     

    Thanks,
    Atanu, Symphony Services

    P.S. Dont forget to mark this as answer, if you have got resolution to your problem from this post.
Page 1 of 1 (3 items)