This is a migrated thread and some comments may be shown as answers.

Best solution for modal popup with partial postback?

1 Answer 295 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Kim
Top achievements
Rank 1
Kim asked on 24 Jul 2014, 05:02 PM
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">
    <ContentTemplate>
            <telerik:RadListBox ID="rlb1" runat="server" Width="200" Height="400">
            </telerik:RadListBox>
            <asp:LinkButton ID="lnkOK" runat="server" Text="OK" />
            <asp:LinkButton ID="lnkCancel" runat="server" Text="Cancel" />
    </ContentTemplate>
</telerik:RadWindow>

Private Sub lnkShowModal_Click(sender As Object, e As System.EventArgs) Handles lnkShowModal.Click
      rlb1.DataSource = cmbList.Items
      rlb1.DataTextField = "Text"
      rlb1.DataValueField = "Value"
      rlb1.DataBind()
   
      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.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Jul 2014, 05:20 AM
Hi Kim,

Please try the below code snippet to achieve your scenario.

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

VB:
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

Thanks,
Shinu.
Tags
Ajax
Asked by
Kim
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or