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

Really stuck.

2 Answers 143 Views
Window
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 14 Feb 2008, 09:44 PM
I've currently got a RadWindow in a survey form, when they click on a link it opens up a new page containing a DataList of prizes they can choose to apply for.

In this DataList, there's a LinkButton that they can click to "select this prize," the LinkButton's CommandArgument is bound to the item number for the prize.
I'd like it if, when they click this LinkButton, it will grab that number, close the Radwindow, and automatically fill a textbox on the parent page with the item number (without posting the page back).

Now, I feel like I'm very, very close to completing this, but I just am not able to make the last hurdle.

And please, don't just point me to any of the examples or other threads or the KB, because I assure you, I've read every relevant one.

What I'm having an issue with right now is filling the textbox with the value.  I've tried all sorts of workarounds, and many different approaches, however since my knowledge of JavaScript isn't that great, I'm stuck.  Here is my code.

prize2.aspx (RadWindow)

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="prize2.aspx.vb" Inherits="prize2" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title>AtHomeNet - Prizes</title> 
</head> 
<body> 
    <script type="text/javascript"
            //This code is used to provide a reference to the radwindow "wrapper" 
            function GetRadWindow() 
            { 
                var oWindow = null
                if (window.radWindow) oWindow = window.radWindow; 
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; 
                return oWindow; 
            }        
                         
            function OK_Clicked() 
            { 
                var oWindow = GetRadWindow(); 
                 
                //Get current content of text area 
                var arg = new Object(); 
                arg.NameValue = document.getElementById("txtItemNumber").value;      
                oWindow.Close(arg);      
            } 
                </script> 
<form id="form1" runat="server"
<textarea  runat="server" id="txtItemNumber" visible="false" rows="1" cols="38"></textarea> 
<asp:DataList id='DataList1' BorderColor="black" CellPadding="0" Font-Names="Verdana" Font-Size="8pt" AlternatingItemStyle-BackColor="#FFFFFF" runat="server"
        <ItemStyle BackColor="White"
           </ItemStyle> 
          <ItemTemplate> 
           <td>  
        <asp:Image ID="Image1" runat="server" ImageUrl="http://www.bondware.com/mod/bcs/photos/Thumb11.gif" /> 
        </td> 
     <td> 
     <table border="0" cellpadding="0" cellspacing="0"
     <tr>  
    <td width="10">&nbsp;</td>    
     <td class="clsCaption" width="350"><b><%#Eval("PrizeTitle")%></b></td> 
      </tr> 
                                                                                                     
    <tr>  
   <td width="10">&nbsp;</td>    
   <td class="clsCaption" width="350"><%#Eval("PrizeDescription")%> 
   <br /><br /> 
 <asp:LinkButton ID="LinkButton1" OnClientClick='OK_Clicked' CommandName="SelectPrize" CommandArgument='<%#Eval("ItemNumber") %>' runat="server">Choose as prize</asp:LinkButton> 
   <br /> 
   <asp:HyperLink ID="HyperLink1" NavigateUrl="#" runat="server">Buy now!</asp:HyperLink> 
   <br /> 
       </td> 
    </tr> 
      </table> 
          </td>  
         </ItemTemplate>   
    </asp:DataList> 
    </form> 
</body> 
</html> 
 
prize2.aspx.vb
Imports System 
Imports System.Collections 
Imports System.ComponentModel 
Imports System.Data 
Imports System.Drawing 
Imports System.Web 
Imports System.Web.SessionState 
Imports System.Web.UI 
Imports System.Web.UI.WebControls 
Imports System.Web.UI.HtmlControls 
 
Partial Class prize2 
    Inherits System.Web.UI.Page 
 
    Dim db As DatabaseHelper = New DatabaseHelper() 
 
    Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load 
        GetPrize() 
    End Sub 
 
    Sub GetPrize() 
        Dim dt As New Data.DataTable 
 
        dt = db.ExecuteDataTable("spp_GetPrize", CommandType.StoredProcedure) 
 
        DataList1.DataSource = dt 
        DataList1.DataBind() 
    End Sub 
    Protected Sub DataList1_ItemCommand(ByVal source As ObjectByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles DataList1.ItemCommand 
        If (e.CommandName = "SelectPrize"Then 
            Session("ItemNumber") = e.CommandArgument 
            txtItemNumber.Value = Session("ItemNumber"
 
        End If 
    End Sub 
End Class 
 
SurveyEntry.aspx (Parent Page)
<script type="text/javascript"
                //Show the window 
                function ShowDialog() 
                {                    
                    //Force reload in order to guarantee that the onload event handler of the dialog which configures it executes on every show. 
                    var oWnd = window.radopen(null, "RadWindow1"); 
                    oWnd.SetUrl(oWnd.GetUrl()); 
                } 
                                                                                         
                function CallBackFunction(radWindow, returnValue) 
                { 
                    if (returnValue.NameValue) document.getElementById("ItemNumber").value = returnValue.NameValue; 
                } 
                 
                // Called when a window is being closed. 
                function OnClientClose(radWindow) 
                {                    
                    //Another option for passing a callback value 
                    //Set the radWindow.Argument property in the dialog 
                    //And read it here --> var oValue = radWindow.Argument;                                      
                    //Do cleanup if necessary 
                }    
                             
            </script> 
 
......................................... 
 
<asp:HyperLink NavigateUrl="#" CssClass="clsLink" id="Prizelink1" Runat="server" Text="one FREE prize from a selection of many"/> 
 
.......................................... 
 
<asp:HyperLink NavigateUrl="#" CssClass="clsLink" id="Prizelink2" Runat="server" Text="Click Here to see Prize List"/>  
                                                                                    </td> 
                                                                                    <td width="200"
                                                                                        <table border="0" cellpadding="0" cellspacing="0"
                                                                                            <tr> 
                                                                                                <td>&nbsp;</td> 
                                                                                            </tr> 
                                                                                         
                                                                                            <tr>   
                                                                                                <td width="10">&nbsp;</td> 
                                                                                                <td> 
                                                                                                  <Textarea ID="ItemNumber" cols="6" rows="1" runat="server" class="clsTextBox"></Textarea></td
                                                                                                     </tr> 
                                                                                             
                                                                                                    <tr> 
                                                                                                <td width="10">&nbsp;</td> 
                                                                                                <td class="clsValidation"><%--<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="ItemNumber" ForeColor="#B0010A" ErrorMessage="Enter an Item Number"></asp:RequiredFieldValidator>--%> 
                                                                                                  </td> 
                      
                                                                                                <telerik:RadWindowManager ID="RadWindowManager1" VisibleOnPageLoad="false" onclientclose="OnClientClose" clientcallbackfunction="CallBackFunction" ReloadOnShow="true" runat="server"
                                                                                                <Windows> 
                                                                                          <telerik:RadWindow 
                                                                                                openerElementId = "<%# Prizelink1.ClientID %>" 
                                                                                                NavigateUrl="prize2.aspx" 
                                                                                                Runat="server" 
                                                                                                Width="650px"    
                                                                                                Skin="Office2007"      
                                                                                                Height="650px" 
                                                                                                Id="Radwindow1" > 
                                                                                         </telerik:RadWindow>  
                                                          
                                                                                         <telerik:RadWindow            
                                                                                                openerElementId = "<%# Prizelink2.ClientID %>"                     
                                                                                                NavigateUrl="prize2.aspx" 
                                                                                                Runat="server" 
                                                                                                Skin="Office2007" 
                                                                                                Width="650px"         
                                                                                                Height="650px" 
                                                                                                Id="Radwindow2" > 
                                                                                         </telerik:RadWindow>     
                                                                                             </Windows> 
                                                                                            </telerik:RadWindowManager> 

This is what I've come up with so far, after many days of banging my head against the wall, and reading everything here.
ANY help would be greatly appreciated.


2 Answers, 1 is accepted

Sort by
0
Peter
Top achievements
Rank 1
answered on 14 Feb 2008, 09:48 PM
Sorry, for the ugly code blocks!
I didn't know it was going to stretch that wide.
0
Peter
Top achievements
Rank 1
answered on 15 Feb 2008, 07:26 PM
Disregard.
Tags
Window
Asked by
Peter
Top achievements
Rank 1
Answers by
Peter
Top achievements
Rank 1
Share this question
or