Best solution for modal popup with partial postback?

2 posts, 0 answers
  1. Kim
    Kim avatar
    15 posts
    Member since:
    Apr 2013

    Posted 24 Jul 2014 Link to this post

    I need to be able to open a modal and bind a RadListBox within the modal at the point in time when the modal opens. Then the user will make selections from the RadListBox and click a button in the modal which needs to cause a partial postback to update a RadComboBox on the main page. I'm struggling to find the right way to achieve this. So far I have a RadWindow control which contains the RadListBox and the button and I found a code example for binding before opening a modal. 

    <telerik:RadWindow ID="rwModal" runat="server" DestroyOnClose="False" Skin="Telerik"
        Modal="True" Width="450" Height="550" Behaviors="None">
                <telerik:RadListBox ID="rlb1" runat="server" Width="200" Height="400">
                <asp:LinkButton ID="lnkOK" runat="server" Text="OK" />
                <asp:LinkButton ID="lnkCancel" runat="server" Text="Cancel" />

    Private Sub lnkShowModal_Click(sender As Object, e As System.EventArgs) Handles lnkShowModal.Click
          rlb1.DataSource = cmbList.Items
          rlb1.DataTextField = "Text"
          rlb1.DataValueField = "Value"
          Dim script As String = "function f(){$find(""" + rwModal.ClientID + """).show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
          ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, True)
      End Sub

    Private Sub lnkOK_Click(sender As Object, e As System.EventArgs) Handles lnkOK.Click
        cmbDeptDCVL.Visible = False
    End Sub

    What is the best way to do a partial postback on lnkOK_Click? I have a RadAjaxManagerProxy on the page already.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 25 Jul 2014 in reply to Kim Link to this post

    Hi Kim,

    Please try the below code snippet to achieve your scenario.

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <telerik:AjaxSetting AjaxControlID="lnkOK">
                    <telerik:AjaxUpdatedControl ControlID="rcdoDemoItems" />

    Protected Sub lnkOK_Click(sender As Object, e As EventArgs)
        rcdoDemoItems.SelectedIndex = 1
        'your code for making updating in combobox
        Dim script As String = "function f(){$find('" + rwModal.ClientID + "').hide(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
        ScriptManager.RegisterStartupScript(Page, Page.GetType](), "key", script, True)
    End Sub

Back to Top