Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Javascript
Hi,
 
I called the javascript function. In that I have to process two process based on the button text. If button text is remove I need to call server side script if it edit I need to call fancybox.
<script type="text/javascript">
 
        function EditandRemove(e) {
            var tmp = document.getElementById(e);
            var tempvalue = tmp.value;
            var courseId = document.getElementById('<%=hidden1.ClientID %>').value
             
            if (tempvalue == "Remove") {
                var record_id = e;
                var tr_id = $(this).parents("#.record");
                alert(tr_id);
                // Ask user's confirmation before delete records
                if (confirm("Do you want to delete this record?")) {
                    $.ajax({
                        type: "POST",
                        //saantc-01.aspx is the page name and DeleteUser is the server side method to delete records in saantc-01.aspx.cs
                        url: "page-01.aspx/DeleteUserDetails",
 
                        //Pass the selected record id
                        data: "{'args': '" + record_id + "','args1': '" + courseId + "','args2': '" + deliveryId + "'}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function () {
                            // Do some animation effect
                            tr_id.fadeOut(500, function () {
                                //Remove GridView row
                                tr_id.remove();
                            });
                        }
                    });
 
                }
                return false;
            }
            else {
                $(e).fancybox({
                    'type': 'iframe',
                    'titlePosition': 'over',
                    'titleShow': true,
                    'showCloseButton': true,
                    'scrolling': 'yes',
                    'autoScale': false,
                    'autoDimensions': false,
                    'helpers': { overlay: { closeClick: false} },
                    'width': 980,
                    'height': 200,
                    'margin': 0,
                    'padding': 0,
                    'overlayColor': '#000',
                    'overlayOpacity': 0.7,
                    'hideOnOverlayClick': false,
                    'href': '/page2.aspx ',
                    'onComplete': function () {
                        $('#fancybox-frame').load(function () {
                            $('#fancybox-content').height($(this).contents().find('body').height() + 20);
                            var heightPane = $(this).contents().find('#content').height();
                            $(this).contents().find('#fancybox-frame').css({
                                'height': heightPane + 'px'
 
                            })
                        });
 
                    }
 
                });
            }
        }
          
    </script>
The above script was not working. Please guide me
 
Button:
 <input id='<%# Eval("userid_pk") %>' type="button" onclick="EditandRemove(this.id);return false;" value="<%= this.hdnButtonName.Value %>" />
Posted 29-Mar-13 21:20pm
Edited 29-Mar-13 22:36pm
(no name)498.5K
v2

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

  Print Answers RSS
0 OriginalGriff 6,569
1 Sergey Alexandrovich Kryukov 6,168
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 30 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100