Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Pass Value from Ifram within ModalPopup to Parent Page

$
0
0

 Hi everyone,

I have two pages "Parent.aspx" and "Popup.asp"

my Parent.aspx like that :

<asp:UpdatePanel ID="UpdatePanel2" runat="server"><ContentTemplate><asp:DropDownList ID="ddl_Trips" runat="server" DataSourceID="SqlDataSource1"
                DataTextField="TripNo" DataValueField="TripID"><asp:ListItem Value="-1">-- Select --</asp:ListItem></asp:DropDownList><asp:SqlDataSource ID="SqlDataSource1" runat="server"
                ConnectionString="<%$ ConnectionStrings:InternationalTransportConnectionString %>"
                SelectCommand="SELECT [TripID], [TripNo] FROM [Trips]"></asp:SqlDataSource><asp:LinkButton ID="LinkButton1" runat="server" Text="Click here to change the paragraph style" /><asp:Panel ID="Panel1" runat="server" Style="display: none" CssClass="modalPopup"><asp:Panel ID="Panel3" runat="server" Style="cursor: move;background-color:#DDDDDD;border:solid 1px Gray;color:Black"><div><p>Choose the paragraph style you would like:</p></div></asp:Panel><div><iframe id="testframe" runat="server" width="240"></iframe><p style="text-align: center;"><asp:Button ID="OkButton" runat="server" Text="OK" /><asp:Button ID="CancelButton" runat="server" Text="Cancel" /></p></div></asp:Panel><cc1:ModalPopupExtender ID="ModalPopupExtender" runat="server"
            TargetControlID="LinkButton1"
            PopupControlID="Panel1"
            BackgroundCssClass="modalBackground"
            OkControlID="OkButton"
            OnOkScript="onOk()"
            CancelControlID="CancelButton"
            DropShadow="true"
            PopupDragHandleControlID="Panel3" /></ContentTemplate></asp:UpdatePanel>

and in code behind :-

protected void Page_Load(object sender, EventArgs e)
    {
        testframe.Attributes["src"] = "../popup/TripsListPopup.aspx?TxtField=" + ddl_Trips.ClientID;
    }


and my popup.aspx

<head runat="server"><title></title><script language="javascript" type="text/javascript">
        function GetRowValue(val, id, ddl) {
            // hardcoded value used to minimize the code.
            // ControlID can instead be passed as query string to the popup window
            window.opener.document.getElementById(ddl).value = id;
            //window.opener.document.getElementById("HiddenField1").value = id;
            window.opener.document.forms(0).submit();
            window.close();
        }</script></head><body><form id="form1" runat="server"><br /><asp:HiddenField ID="hf_ddl" runat="server" /><table width="60%"><tr><td><div class="grid"><div class="rounded"><div class="top-outer"><div class="top-inner"><div class="top"><h2><asp:Label ID="Label1" runat="server" Text="Trips Data"></asp:Label></h2></div></div></div><div class="mid-outer"><div class="mid-inner"><div class="mid"> <!-- Content Goes Here! --><asp:GridView ID="GV_Tips" runat="server" AutoGenerateColumns="False" 
                             CssClass="datatable" AllowPaging="True"
                            CellPadding="0" BorderWidth="0px"
                            SortedAscendingHeaderStyle-CssClass="sortasc" SortedDescendingHeaderStyle-CssClass="sortdesc"
                            SortedAscendingCellStyle-CssClass="sortasc" 
                        SortedDescendingCellStyle-CssClass="sortdesc" DataKeyNames="TripID" 
                        onrowdatabound="GV_Tips_RowDataBound" 
                        DataSourceID="SqlDataSource1" PageSize="15"><PagerStyle CssClass="pager-row" /><RowStyle CssClass="row" /><PagerSettings 
                                Mode="NumericFirstLast" PageButtonCount="7"
                                FirstPageText="«" LastPageText="»"  />      <Columns><asp:TemplateField HeaderText="#"><ItemTemplate><%# Container.DataItemIndex + 1 %></ItemTemplate><ItemStyle Width="20px" /></asp:TemplateField><asp:TemplateField HeaderText="Trip No" SortExpression="TripNo"><ItemTemplate><asp:Label ID="lbl_TripNo" runat="server" Text='<%# Bind("TripNo") %>'></asp:Label></ItemTemplate></asp:TemplateField><asp:BoundField DataField="CountryName" HeaderText="Country Name" 
                                    SortExpression="CountryName" /><asp:BoundField DataField="ShipAgent" HeaderText="Ship Agent" 
                                    SortExpression="ShipAgent" /><asp:BoundField DataField="OuterAgent" HeaderText="Outer Agent" 
                                    SortExpression="OuterAgent" /><asp:BoundField DataField="TripDateM" DataFormatString="{0:dd/MM/yyyy}" 
                                    HeaderText="Trip Date" SortExpression="TripDateM" /><asp:TemplateField><ItemTemplate><asp:ImageButton ID="ImageButton1" runat="server" 
                                            ImageUrl="~/images/options.gif" /><asp:HiddenField ID="hf_TripID" runat="server" 
                                            Value='<%# Eval("TripID") %>' />    </ItemTemplate></asp:TemplateField></Columns></asp:GridView><asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:InternationalTransportConnectionString %>" 
                        SelectCommand="SELECT XTripStatus.TripStatus, Trips.TripNo, Trips.TripDateM, Trips.TripDateH, XCountries.CountryName, Agents_1.AgentName AS ShipAgent, Agents.AgentName AS OuterAgent, Trips.TripID FROM Trips INNER JOIN XCountries ON Trips.CountryID = XCountries.CountryID INNER JOIN XTripStatus ON Trips.TripStatusID = XTripStatus.TripStatusID LEFT OUTER JOIN Agents ON Trips.OuterAgentID = Agents.AgentID AND XCountries.CountryID = Agents.CountryID LEFT OUTER JOIN Agents AS Agents_1 ON Trips.ShipAgentID = Agents_1.AgentID AND XCountries.CountryID = Agents_1.CountryID WHERE (Trips.TripStatusID <> 5)"></asp:SqlDataSource></div></div></div><div class="bottom-outer"><div class="bottom-inner"><div class="bottom"></div></div></div></div></div>        </td></tr></table></form></body>


and in code behind :

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["TxtField"] != null)
            {
                hf_ddl.Value = Request.QueryString["TxtField"];
            }
        }
    }

    protected void GV_Tips_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if ((e.Row.RowType == DataControlRowType.DataRow))
        {
            //assuming that the required value column is the second column in gridview 
            ((ImageButton)e.Row.FindControl("ImageButton1")).Attributes.Add("onclick", "javascript:GetRowValue('" + ((Label)e.Row.FindControl("lbl_TripNo")).Text + "','" + ((HiddenField)e.Row.FindControl("hf_TripID")).Value + "','" + hf_ddl.Value
                + "')");

        }
    }


now i want when i click on button in parent page open modalpopup with iframe and when i select row from Gridview in popup page pass value to the parent dropdownlist and reload page

Help me please

Thank you





Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>