1 Replies - 3620 Views - Last Post: 18 May 2013 - 07:20 AM Rate Topic: -----

#1 low1988  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 10-August 09

Trigger Postback in Jquery Modal Popup from Grid View Item

Posted 08 May 2013 - 03:03 AM

I have a grid view control with list of rows items. Each rows has a button which would triggers a client side pop up modal form to ask the user to enter some data before continue to execute the server side method. The problem is I cant find a way to continue the postback after the user clicked 'Confirm' button on the modal form. Most importantly, the server side method is reside within a DataGrid OnItemCommand Event. Before the method would be executed, several parameters from the other column in the same row would be collected. Any idea to deal with this ? Appreciate so much for anyone can solve it.


//Page aspx
    
    <head>
    <link href="jquery-ui-1.7.2.custom.css" type="text/css" rel="stylesheet"/>
    <script src="../../Javascript/jquery-1.4.2.min.js" type="text/javascript">
    </script>
    <script src="../../Javascript/jquery-ui-1.8.2.custom.min.js" type="text/javascript">
    </script>
    
    <script type="text/javascript">
    
            $(document).ready(function () {
    
                     $('#dialog').dialog({
                    autoOpen: false,
                    height: 280,
                    modal: true,
                    resizable: false,
                    open: function(type, data) {$(this).parent().appendTo("form");},
                    buttons: {
                        'Cancel': function () {
                            $(this).dialog('close');
                            // Submit Rating
                            return false;
                        },
                        'Confirm': function () {
                            $(this).dialog('close');
                            // Update Rating
                        }
                    }
                });
    
            });
    
            function employeeNumberModal() {
    
                $('#dialog').dialog('open');
    
            }
        
        </script>
    
    </head>
    
     <form id="Form1" method="post" runat="server">
     <div>
    <asp:Grid ID="grid" runat="server">
    
    <asp:BoundColumn Visible="False" DataField="cand_id" SortExpression="cand_id">
    </asp:BoundColumn>
    <asp:BoundColumn Visible="False" DataField="job_post_id" SortExpression="job_post_id">
    </asp:BoundColumn>
    <asp:BoundColumn Visible="False" DataField="schd_id" SortExpression="schd_id">
    </asp:BoundColumn>
    
    <asp:TemplateColumn>
     <ItemStyle HorizontalAlign="Center"></ItemStyle>
     <ItemTemplate>
     <asp:Button ID="btnSync" runat="server" Text="Sync Employee" OnClientClick="if(!employeeNumberModal()) return false;"
     CommandName="Sync"></asp:Button>
      </ItemTemplate>
     /asp:TemplateColumn>
    
    </asp:SuperGrid>
    </div>
    
    <div id="dialog" title="New Employee Number">
    <p>Please enter new employee number for the candidate</p>
    <p><asp:TextBox ID="txtNewEmpNo" runat="server" Width="80%"></asp:TextBox></p>
    </div>
    
    </form>
    
    //code behind
    
    this.grid.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.grid_ItemCommand);
    
    private void grid_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
    	switch (e.CommandName)
        {
    		case "Sync":
                        CandidateBusiness candBizObj = new CandidateBusiness();
                        candBizObj.CandidateId = e.Item.Cells[0].Text;
                        candBizObj.JobPostId = e.Item.Cells[1].Text;
                        candBizObj.ScheduleId = e.Item.Cells[2].Text;
                        candBizObj.SyncToEmployee();
    					break;
    	}
    }
    




Is This A Good Question/Topic? 0
  • +

Replies To: Trigger Postback in Jquery Modal Popup from Grid View Item

#2 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,511
  • Joined: 16-March 11

Re: Trigger Postback in Jquery Modal Popup from Grid View Item

Posted 18 May 2013 - 07:20 AM

Why don't you place the code under the click event of the button that brings up the modal? Then you just make sure the button is going to be posting back somewhere or force the window.location to change on click. It's your call. Example:

$('#GridButton').click(function () {
var x=confirm('Are you sure?');

if (x == True) {
return true;
}
else
{
return false;
}

});



Let me know if we're on the right track here.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1