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

radwindow repeater selection back to parent

4 Answers 158 Views
Window
This is a migrated thread and some comments may be shown as answers.
AName
Top achievements
Rank 1
AName asked on 30 Apr 2014, 01:18 PM
Hi there,

I have a radwindow that performs a search on data and displays a list within a repeater of options the user may select.
What I need to do is collect the repeater object and send back to the parent. 

I looked at some of your examples using javascript, the problem is using javascript to grab the data within the repeater is quite ugly.

Is there a way I can pass the code back via code behind?
So in my repeater I have a button "select" when user clicks the "select" button the radwindow closes and
the parent receives the selection. 

My repeater code

​<asp:Repeater ID="rptStores" runat="server" OnItemDataBound="rptStores_ItemDataBound">
<HeaderTemplate>
<table>
<tr style="color:#ffd700; font-weight:bold;">
<td>Store Name</td>
<td>City</td>
<td>Street</td>
<td>Distance(Mi.)</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="color:#fff;" onmouseover="this.style.backgroundColor='blue'" onmouseout="this.style.backgroundColor=''" class="<%# If(Container.ItemIndex Mod 2 = 0, "TRNormal", "TRAlt") %>">
<td style="padding: 4px;">
<asp:Label ID="lblDBAName" runat="server" Text='<%# Eval("DBAName") %>' />
<asp:HiddenField ID="hfRowID" runat="server" Value='<%# Eval("id") %>' />
</td>
<td style="padding: 4px;">
<asp:Label ID="lblCity" runat="server" Text='<%# Eval("State") +"-"+ Eval("City")%>' />
<asp:HiddenField ID="hfState" runat="server" Value='<%# Eval("state") %>' />
</td>
<td style="padding: 4px;">
<asp:Label ID="lblStreet" runat="server" Text='<%# Eval("Street1") %>' />
<asp:HiddenField ID="hfPhone" runat="server" Value='<%# Eval("phone") %>' />
</td>
<td style="padding: 4px;">
<asp:Label ID="lblDistance" runat="server" Text='<%# Eval("distance") %>' />
</td>
<td>
<telerik:RadButton runat="server" Text="Select" ID="storeSelection2" CommandName="Process" Skin="Black" OnClientClicked="returnToParent"></telerik:RadButton>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>
<asp:Label ID="lblEmptyData" Text="No Data To Display" runat="server" Visible="false"></asp:Label>
</td>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>


my vb

Protected Sub rptStores_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles rptStores.ItemCommand

Dim dbaName As Label
dbaName = CType(e.Item.FindControl("lblDBAName"), Label)

Dim city As Label
city = CType(e.Item.FindControl("lblCity"), Label)

Dim state As HiddenField
state = CType(e.Item.FindControl("hfState"), HiddenField)

Dim phone As HiddenField
phone = CType(e.Item.FindControl("hfPhone"), HiddenField)

Dim street1 As Label
street1 = CType(e.Item.FindControl("lblStreet"), Label)

Dim selectedID As HiddenField
selectedID = CType(e.Item.FindControl("hfRowID"), HiddenField)

ProcessButton(dbaName.Text, street1.Text, city.Text, state.Value, phone.Value, selectedID.Value)

End Sub

ProcessButton is called AFTER a return to parent javascript call.

Is this an option or do i really need to send object via javascript back to parent and then push into code behind.

4 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 02 May 2014, 02:39 PM

Hello,

If the code in the RadWindow is in its own page, you can store data on the server, e.g., in the Session, so you can access it from the code-behind of the main page. You would still need some JavaScript to close the RadWindow and invoke a function on the main page that will POST it.

Another option is to use the ContentTemplate of the RadWindow so the repeater is a part of the main page, which will let you access all control in it. The following demo shows the difference in accessing the controls and lists the pros and cons: http://demos.telerik.com/aspnet-ajax/window/examples/contenttemplatevsnavigateurl/defaultcs.aspx. You may also find useful this article on using AJAX in this scenario: http://www.telerik.com/help/aspnet-ajax/radwindow-ajaxifying.html.


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.

 
0
Julius
Top achievements
Rank 1
answered on 07 Jul 2016, 06:02 AM

Hi Marin,

I tried putting in repeater inside RadWindow's ContentTemplate, but when saving the records, the values of the textbox inside repeater's itemtemplate is not according to what I put in, i.e. still the original data bound values. Is this a problem with the viewstate? Please find my code below. When I open the RadWindow, and change values in tbSequence, and hit a button click, the values are still the original databound values. Can you please advise?

<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
        <Windows>
            <telerik:RadWindow ID="radBuildingPhotoEdit" runat="server" Title="Edit Building Photos" Width="700" Height="700" Modal="true" OnLoad="radBuildingPhotoEdit_Load"
                Behaviors="Minimize, Move, Resize, Maximize, Close" ViewStateMode="Enabled">
                <ContentTemplate>
                    <p>
                        <asp:FileUpload ID="fuBuildingPhoto" runat="server" />
                        <asp:Button ID="btnUploadBuildingPhoto" runat="server" Text="<%$ KFTranslate:Upload Photo%>" CausesValidation="false" OnClick="btnUploadBuildingPhoto_Click" />
                        <asp:Button ID="btnUpdateBuildingImageOrder" runat="server" Text="<%$ KFTranslate:Update Order%>" ValidationGroup="BuildingPhotos"
                            ToolTip="<%$ KFTranslate:Click on this button to update the order of building images%>" OnClick="btnUpdateBuildingImageOrder_Click" />            
                    </p>
                    <asp:Repeater ID="rptBuildingPhotosEdit" runat="server" OnItemDataBound="rptBuildingPhotosEdit_ItemDataBound" OnItemCommand="rptBuildingPhotosEdit_ItemCommand">
                        <ItemTemplate>
                            <div class="rptImages">                        
                                <asp:TextBox ID="tbSequence" runat="server" CssClass="tbSequence" Text='<%#Eval("Sequence") %>' onkeypress="return isNumberKey(event)" />
                                <asp:RequiredFieldValidator ID="reqSequence" runat="server" ControlToValidate="tbSequence" ValidationGroup="BuildingPhotos" ErrorMessage="*" 
                                    SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
                                <div style="margin-top: 5px">
                                    <asp:Image ID="imgBuildingPhoto" runat="server" />
                                    <asp:ImageButton ID="imgDeleteBuildingPhoto" runat="server" ImageUrl="~/Images/cross.png" Style="vertical-align: top"
                                        CommandName="Delete" CommandArgument='<%#Eval("ImageID") %>' OnClientClick="javascript:return confirm(document.getElementById('hidMsgConfirmDelete').value);" />
                                </div>
                                <asp:Label ID="lblImageID" runat="server" Visible="false" Text='<%#Eval("BuildingLeaseSuiteImageID") %>'></asp:Label>
                            </div>
                        </ItemTemplate>
                    </asp:Repeater> 
                </ContentTemplate>
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>

 

 

0
Marin Bratanov
Telerik team
answered on 07 Jul 2016, 07:31 AM

Hi Julius,

This shouldn't be happening and my best suggestion at the moment is to move this RadWindow out of the RadWindowManager, because when its ContentTemplate is used, a change in the server lifecycle may occur, as described here.

Regards,

Marin Bratanov
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Julius
Top achievements
Rank 1
answered on 10 Jul 2016, 11:30 PM
Thanks Marin. It works fine now :)
Tags
Window
Asked by
AName
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Julius
Top achievements
Rank 1
Share this question
or