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

ModalPopupExtender in an ASCX cannot return value

$
0
0

I have an ASCX  form  call it ASCX-1 that opens another ascx ModalPopupExtender that displays a listview call it ASCX-2. ASCX-1 sends a paramter to ASCX-2 which opens fine. However, upon making a selection I want to fill in a textbox on ASCX-1 based on the selection made on ASCX-2.

ASCX-1:

<table border="0"><tr><td  align="right" width="90px"><asp:Label ID="Label_comments" runat="server" Text="Comments" CssClass="Form_Label_Font"></asp:Label></td><td  align="left" width="340px"><asp:TextBox ID="txt_comments" runat="server" Text='<%# Bind("comments") %>' CssClass="Form_Input_Font" MaxLength="200" Width="340" Rows="4" TextMode="MultiLine" ></asp:TextBox></td><td  align="left" width="20px"><asp:PlaceHolder ID="Comments_PlaceHolder" runat="server"    /></td></tr></table>

In the code behind I call ASX-2 via the Comments_PlaceHolder

This is the ASCX-2

<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="comments_popup.ascx.vb" Inherits="wo.comments_popup" %><%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %><asp:UpdatePanel ID="UpdatePanel_Comments_PopUp" UpdateMode="Conditional" runat="server"  EnableViewState="false"  ><ContentTemplate><table style="border-width: 0"><tr><td style="width: 18px; text-align:left; vertical-align: top; background-color:#349cf1;"><asp:Button ID="Comments_PopUpButton" runat="server" BorderWidth="0" Width="18px"
                                        Text="..."
                                         Height="25px"  BackColor ="#349cf1"
                                         Font-Names="Tahoma,Arial, Verdana"
                                         ForeColor="White" Font-Size="11px" /></td></tr></table><asp:ModalPopupExtender ID="ModalPopupExtender_Comments" runat="server" BackgroundCssClass="modalBackground"
    DropShadow="true" TargetControlID="Comments_PopUpButton" PopupControlID="Comments_Panel" 
    CacheDynamicResults="false" CancelControlID="ImageButton_Back" ></asp:ModalPopupExtender><asp:Panel ID="Comments_Panel" runat="server" BackColor="#c6e0f9"  Style="display: none"
    CssClass="modalPopup" ><table style="width: 600px" ><tr><td style="width: 46px; background-color: #4A4344; text-align: center; vertical-align: top"><asp:ImageButton ID="ImageButton_Back" runat="server" ImageUrl="../images/nav/white/back.png"
                    Width="36px" Height="36px"  /></td><td style="width: 10px; background-color:inherit; text-align: center; vertical-align: top">&nbsp;</td><td><asp:Label ID="lbl_Select" runat="server" Text="Comments:" CssClass="Form_SubTitle_Font" /><div id="Div_ListView_Comments" style="height: 270px; overflow: auto; border: 2 solid black;"><asp:ListView ID="ListView_Comments" runat="server" DataKeyNames="wo_comments_uniqueid" 
                                    DataSourceID="SqlDataSource_comments_PopUp" OnSelectedIndexChanged="ListView_Comments_SelectedIndexChanged"><LayoutTemplate><table><tr runat="server" id="itemPlaceholder"></tr></table></LayoutTemplate><ItemTemplate><tr><td style="width: 460px; text-align: left; vertical-align:top;"><asp:Label ID="lbl_comments" runat="server" Text='<%# eval("comments") %>' CssClass="Form_Input_Font" Width="460" /><asp:HiddenField ID="Hidden_wo_comments_uniqueid" runat="server" Value='<%# Bind("wo_comments_uniqueid")%>' /></td><td style="width: 55px; vertical-align:top"><asp:Button ID="Button_Select" runat="server" Text="Select" CommandName="Select" 
                                                    Width="45px" Height="40px" CssClass="Button_ListView_Style" Style="background-image: url(~/images/nav/white_nc/check_sm.png);
                                                    background-repeat: no-repeat; background-position: center;"  /></td></tr><tr><td width="455px" align="left" colspan="2"><div style="height: 1px; background-color: #70DB93; width: 455px; float: inherit;
                                                    border: 0" /></td></tr></ItemTemplate><EmptyDataTemplate><asp:Label ID="lbl_EmptyPopUp" runat="server" Text="No comments information was returned"
                                            CssClass="Form_Input_Font" /></EmptyDataTemplate></asp:ListView></div></td></tr></table></asp:Panel></ContentTemplate></asp:UpdatePanel>

Here is the code-behind of ASCX-2

Public Class comments_popup
    Inherits System.Web.UI.UserControl

    Private _WO_Type_Uniqueid As Guid
    Public Property WO_Type_Uniqueid As Guid
        Get
            Return _WO_Type_Uniqueid
        End Get
        Set(ByVal value As Guid)

            _WO_Type_Uniqueid = value

        End Set
    End Property



    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       
    End Sub

    Protected Sub SqlDataSource_comments_PopUp_Selecting(sender As Object, e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource_comments_PopUp.Selecting
        e.Command.Parameters("@WO_Type_Uniqueid").Value = _WO_Type_Uniqueid

        ListView_Comments.DataBind()
    End Sub

    Protected Sub ListView_Comments_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ListView_Comments.SelectedIndexChanged

        Dim _txt_comments As TextBox
        _txt_comments = CType(Parent.FindControl("txt_comments"), TextBox)
        _txt_comments.Text = _txt_comments.Text & " Pop Up Test"

    End Sub


   
End Class

 

In the code-behind I am not actually grabbing the data just passing some test data for now. In the SelectedIndexChanged I put a break point and if I view the contents _text_comment.text its returning the data from the parent TextBox. However if I try to change the value as soon as the modalpopup closes the value doesn't change on the parent. I also tried tracing the parent and it seems the value does come back to the parent but for some reason resets back to the original value.

Any suggestions?


Viewing all articles
Browse latest Browse all 5678

Trending Articles



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