Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have some VB code. I want to see what button was clicked on popupmodelextender, my problem is it does not pop up, so cant see what button was pressed.

So my Question is how to make modal pop up and how use an IF statement to see ik OK or cancel was pressed.

VB
Dim success As Boolean = False
        Dim PTC_ID As Integer
        Dim btnDelete As Button = TryCast(sender, Button)
        Dim row As GridViewRow = DirectCast(btnDelete.NamingContainer, GridViewRow)

        Dim cmdDelete As New SqlCommand("p_deleteProtocolStructure", MyConnManagement)

        PTC_ID = grdQuestions.DataKeys(row.RowIndex).Values("PTC_ID")
        '--==IF Statement to see if stored proc returns anything==--'
        Dim sqlString As String = String.Empty
        'SQL CONN'
        Dim sqlConnDelProtocol As New SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("MyConn").ConnectionString)
        sqlConnDelProtocol.Open()
        'DATA ADAPTER'
        Dim sqlDataAdapDelProtocol As New SqlClient.SqlDataAdapter(sqlString, sqlConnDelProtocol)
        sqlDataAdapDelProtocol.SelectCommand.CommandType = CommandType.StoredProcedure
        'DATASET'
        Dim cmdLinkedProcudures As New SqlCommand("p_GetLinkedProcuduresProtocol", sqlConnDelProtocol)
        cmdLinkedProcudures.CommandType = CommandType.StoredProcedure
        cmdLinkedProcudures.Parameters.AddWithValue("PTC_ID", PTC_ID)

        Dim dsProtocolLinked As New DataSet
        sqlDataAdapDelProtocol.SelectCommand = cmdLinkedProcudures
        sqlDataAdapDelProtocol.Fill(dsProtocolLinked, "ProtocolsLinked")

        If dsProtocolLinked.Tables("ProtocolsLinked").Rows.Count > 0 Then
            '--==DELETE PROTOCOL==--'
            cmdDelete.CommandType = CommandType.StoredProcedure
            cmdDelete.Parameters.AddWithValue("PTC_ID", PTC_ID)
            '--==END DELETE PROTOCOL==--'
            cmdDelete.Connection = conn
        Else
            mdlQuestions.Show()'<--Not sure what to do there
            If btnPTCOk.OnClientClick Then '<--Not sure what to do there
                cmdDelete.CommandType = CommandType.StoredProcedure
                cmdDelete.Parameters.AddWithValue("PTC_ID", PTC_ID)
            End If

        End If


my Ajax and JAvaScript

        function showConfirm(source){
            this._source = source;
            
            var ctrl;
            ctrl=_source.id;
            
            if (ctrl.indexOf('btnDeletePTS')>0) {
                this._popup = $find('mdlProtocols');
            } else if (ctrl.indexOf('btnDeletePTC')>0) {
                this._popup = $find('mdlQuestions');
            } else if (ctrl.indexOf('imgbtn')>0) {
                this._popup = $find('mdlReorder');
            }
            
            if (this._popup) {this._popup.show();};
            
        }
        
        function okClick(){
            this._popup.hide();
            __doPostBack(this._source.name, '');
        }
        
        function cancelClick(){
            //Dispose popup 
            this._popup.hide();
            this._source = null;
            this._popup = null;
        }




AJAX

<div id="PTCModalDiv"  runat="server" style="display:none; width: auto;" class="modalPopup" align="center" nowrap="nowrap">
                                <img src="../App_Themes/Main/images/warning.jpg" alt="" />Are you sure you want to delete this Question?<br />
                                <asp:Button ID="btnPTCOk" runat="server" SkinID="ActionButtonsYes" OnClientClick="okClick" />
                                <asp:Button ID="btnPTCNo" runat="server" SkinID="ActionButtonsNo" OnClientClick="cancelClick" />
                            </div>
                            <ajaxToolKit:ModalPopupExtender 
                                 runat="server" ID="mdlQuestions" DropShadow="true"
                                TargetControlID="PTCModalDiv" PopupControlID="PTCModalDiv" 
                                OkControlID="btnPTCOk" CancelControlID="btnPTCNo" BackgroundCssClass="modalBackground" 
                                OnOkScript="okClick()"  önCancelScript="cancelClick()" />
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900