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

Update window content before opening

1 Answer 12 Views
Window
This is a migrated thread and some comments may be shown as answers.
Mickael
Top achievements
Rank 1
Mickael asked on 08 Oct 2014, 04:08 AM
I am trying to open a window with a label set from code behind.
The window opens but the label is not set

<telerik:RadCodeBlock ID="RadCodeBlock2" runat="server">
    <script type="text/javascript" language="javascript">
        function aspButtonCallbackFn(sender, args) {
            PageMethods.PrepareForSearchResult(args.get_text(), MyMethod_Result);
        }
 
        function MyMethod_Result(pResult) {
            if (pResult == 2) {
                    var wnd = $find("<%=modalPopup.ClientID %>");
                    wnd.show();
                }
    }
    </script>
</telerik:RadCodeBlock>

This is how the popup is declared:

<telerik:RadWindow
    ID="modalPopup"
    runat="server"
    AutoSizeBehaviors="Width, Height"
    AutoSize="true"
    VisibleStatusbar="false"
    Behaviors="Move"
    VisibleOnPageLoad="false"
    ReloadOnShow="true"
    Modal="true"
    EnableShadow="true">
    <ContentTemplate>
        <asp:UpdatePanel ID="PdtPnl_ForAddExisting" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <div style="display: table; width: 100%">
                    <div style="display: table-row; vertical-align: middle">
                        <div style="display: table-cell; padding-top: 10px; padding-left: 10px; padding-bottom: 5px; padding-right: 10px;">
                            <asp:Label
                                ID="Lbl_Pnl_ForAddExisting"
                                runat="server"
                                Text="" />
                        </div>
                    </div>
                </div>
                <div style="display: table; width: 100%">
                    <div style="display: table-row; vertical-align: middle">
                        <div style="display: table-cell; padding-top: 5px; padding-left: 10px; padding-bottom: 10px; padding-right: 5px;">
                            <asp:Button
                                ID="Bttn_Add_ForAddExisting"
                                Width="100"
                                OnClick="Bttn_Add_ForAddExisting_Click"
                                Text="Add"
                                runat="server"
                                class="button" />
                        </div>
                        <div style="display: table-cell; padding-top: 5px; padding-left: 5px; padding-bottom: 10px; padding-right: 10px;">
                            <asp:Button
                                ID="Bttn_Cancel_ForAddExisting"
                                Width="100"
                                OnClick="Bttn_Cancel_ForAddExisting_Click"
                                Text="Cancel"
                                runat="server"
                                class="button" />
                        </div>
                    </div>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </ContentTemplate>
</telerik:RadWindow>

And this is the WebMethod

[WebMethod]
public static int PrepareForSearchResult(string pText)
{
    if (String.IsNullOrEmpty(pText) == true)
    {
        return -1;
    }
    _instance.Lbl_Pnl_ForAddExisting.Text = String.Format("Do you want to add '{0}'?", pText);
    _instance.PdtPnl_ForAddExisting.Update();
    return 2;
}

Not sure what I am doing wrong.

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 08 Oct 2014, 10:09 AM

Hi Michael,

Page methods should be considered as an easy to use webservice. They return JSON and not an HTML response for the page. They are static members of the page class, so they cannot use control instances from the page (i.e., concrete controls). You can read more about it here: http://blogs.telerik.com/aspnet-ajax/posts/13-03-21/different-ways-to-make-a-request-to-the-server.

If you can manage to get this working without the RadWindow, the same approach should work with the RadWIndow as well.

What I would suggest is returning the needed data from the page method and using JavaScript to set it to the span where you want it.


Regards,

Marin Bratanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Window
Asked by
Mickael
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or