Click here to Skip to main content
15,867,921 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
C#
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
      
        $(document).ready(function () {
            $('#DisableDiv').append('<div style=background-color:#5D6165;position:absolute;top:0;left:0;width:100%;height:100%;z-index:1001;-moz-opacity:0.8;opacity:.80;filter:alpha(opacity=80);><img src=../UIAssets/Inclub/Images/loaderAnim.gif style=background-color:Aqua;position:absolute;top:50%;left:44%;width:147px;height:36px;/></div>');

            var QS = window.location.href.slice(window.location.href.indexOf('?') + 1).split('=');
            var QSplit = QS[1].split(',');
            if (QSplit.length == 5) {
                var TrimCatName = QSplit[1];
                TrimCatName = TrimCatName.replace(/\^/g, ' ');
                $("#txtCatEdit").val(TrimCatName);
                if (QSplit[4] == "Active")
                    document.getElementById('MainContent_cbActive').checked = true;
                else if (QSplit[4] == "InActive")
                    document.getElementById('MainContent_cbActive').checked = false;
                if (QSplit[2] == 1) {
                    $("#spnMemberShipType").text("Flex");
                    $("#trWT").show();
                    $("#trWT1").show();
                    $("#divWT").show();
                    $("#trFixedPrice").hide();
                }
                else if (QSplit[2] == 2) {
                    $("#spnMemberShipType").text("Fixed");
                    $("#trWT").hide();
                    $("#trWT1").hide();
                    $("#divWT").hide();
                    $("#trFixedPrice").show();
                    if (QSplit[3] == 0) {
                        $.ajax({
                            type: "POST",
                            url: "EditCategory.aspx/GetFlexRate",
                            data: "{'CatId': '" + QSplit[0] + "'}",
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function (data) {
                                $("#txtFixedPrice").val(data.d);
                            },
                            error: function (result) {
                                alert(" Error");
                            }
                        });
                    }
                }
                if (QSplit[3] == 0) {
                    $.ajax({
                        type: "POST",
                        url: "EditCategory.aspx/GetCategoryWorkOuts",
                        data: "{'CatId': '" + QSplit[0] + "'}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (data) {
                            var len = data.d.length;
                            for (var i = 0; i < data.d.length; i++) {
                                $("#spnCount").text(data.d.length);
                                if (data.d[i].WorkOutType == "b") {
                                    idval = eval(i) + 1;
                                    var ftxtid = "txt" + idval + "1";
                                    var stxtid = "txt" + idval + "2";
                                    var thtxtid = "txt" + idval + "3";
                                    document.getElementById('MainContent_rbtnWrkOutType_0').checked = true;
                                    $("#divWorkOuts").append('<div style="float: left; width: 60%;"><input onkeypress="return onlyNos(event,this);" onblur="return check1txtBWO(this);"  type="text" id=' + ftxtid + ' value=' + data.d[i].minWorkoutRate + '  style="width: 50px;" />&nbsp;to&nbsp;<input onkeypress="return onlyNos(event,this);" onblur="return check2txtBWO(this);" style="width: 50px;" id=' + stxtid + ' value=' + data.d[i].WorkOuts + ' type="text" /></div><div style="float: left; width: 40%;"><input onkeypress="return isNumber(event)" onblur=getnewrowBWO(this); type="text" id=' + thtxtid + '  value=' + data.d[i].Cost + ' style="width: 50px;" /></div>');
                                }
                                else if (data.d[i].WorkOutType == "s") {
                                    idval = eval(i) + 1;
                                    var ftxtid = "txt" + idval + "1";
                                    var stxtid = "txt" + idval + "2";
                                    document.getElementById('MainContent_rbtnWrkOutType_1').checked = true;
                                    $("#divWorkOuts").append('<div style="float: left; width: 60%;"><input onkeypress="return onlyNos(event,this);"  onblur="return WorkOutValidation(this);"  style="width: 50px;" id=' + ftxtid + ' value=' + data.d[i].WorkOuts + ' type="text" /></div><div  style="float: left; width: 40%;"><input onkeypress="return isNumber(event)"  onblur=getnewrow(this); type="text"  id=' + stxtid + '  value=' + data.d[i].Cost + ' style="width: 50px;" /></div>');

                                }
                            }
                            if (data.d[0].WorkOutType == "b") {
                                len = eval(len) + 1;
                                var ftxtid = "txt" + len + "1";
                                var stxtid = "txt" + len + "2";
                                var thtxtid = "txt" + len + "3";
                                $("#divWorkOuts").append('<div style="float: left; width: 60%;"><input onkeypress="return onlyNos(event,this);" onblur="return check1txtBWO(this);" type="text" id=' + ftxtid + ' value="" style="width: 50px;" />&nbsp;to&nbsp;<input onkeypress="return onlyNos(event,this);" onblur="return check2txtBWO(this);" style="width: 50px;" id=' + stxtid + ' value="" type="text" /></div><div style="float: left; width: 40%;"><input onkeypress="return isNumber(event)"  onblur=getnewrowBWO(this); type="text" id=' + thtxtid + '  value="" style="width: 50px;" /></div>');

                            }
                            else if (data.d[0].WorkOutType == "s") {
                                len = eval(len) + 1;
                                var ftxtid = "txt" + len + "1";
                                var stxtid = "txt" + len + "2";
                                $("#divWorkOuts").append('<div style="float: left; width: 60%;"><input onkeypress="return onlyNos(event,this);"  onblur="return WorkOutValidation(this);"  style="width: 50px;" id=' + ftxtid + ' value="" type="text" /></div><div style="float: left; width: 40%;"><input onkeypress="return isNumber(event)"  onblur=getnewrow(this); type="text"  id=' + stxtid + '  value="" style="width: 50px;" /></div>');

                            }
                            $('#DisableDiv').html("");
                        },
                        error: function (result) {
                            alert(" Error");
                        }
                    });
                }
                else if (QSplit[3] == 1) {
                    if (QSplit[2] == 1) {
                        alert("Select WorkOuts Types and Assign");
                    }
                    $("#MainContent_rbtnWrkOutType_1").click(function () {
                        $("#spnCount").text(0);
                        var ftxtid = "txt11";
                        var stxtid = "txt12";
                        $("#divWorkOuts").append('<div style="float: left; width: 60%;"><input onkeypress="return onlyNos(event,this);"  onblur="return WorkOutValidation(this);"  style="width: 50px;" id=' + ftxtid + ' value="" type="text" /></div><div style="float: left; width: 40%;"><input  onkeypress="return isNumber(event)" onblur=getnewrow(this); type="text"  id=' + stxtid + '  value="" style="width: 50px;" /></div>');

                    });
                    $("#MainContent_rbtnWrkOutType_0").click(function () {
                        $("#spnCount").text(0);
                        var ftxtid = "txt11";
                        var stxtid = "txt12";
                        var thtxtid = "txt13";
                        $("#divWorkOuts").append('<div style="float: left; width: 60%;"><input onkeypress="return onlyNos(event,this);" onblur="return check1txtBWO(this);" type="text" id=' + ftxtid + ' value="" style="width: 50px;" />&nbsp;to&nbsp;<input onkeypress="return onlyNos(event,this);" onblur="return check2txtBWO(this);" style="width: 50px;" id=' + stxtid + ' value="" type="text" /></div><div style="float: left; width: 40%;"><input onkeypress="return isNumber(event)" onblur=getnewrowBWO(this); type="text" id=' + thtxtid + '  value="" style="width: 50px;" /></div>');

                    });
                    $('#DisableDiv').html("");
                }
            }
            else
                location.href = "Category.aspx";
        });
       
        function getnewrow(a) {

            var id = $(a).attr('id').split('txt');
            var PreID = eval(id[1]) - eval(10);
            var thisIdVal = $(a).val();
            var PreIDVal = $("#txt" + PreID).val();
            var thisIdWO = eval(id[1]) - 1;
            var PreIdWo = eval(PreID) - 1;
            var thisIdWOval = $("#txt" + thisIdWO).val();
            var PreIdWoVal = $("#txt" + PreIdWo).val();

            if (eval(thisIdVal) >= eval(PreIDVal)) {
                alert("this Price should be Less than Previous value");
                $(a).val("");
                $(a).focus();
            }
            else if (eval(thisIdWOval) <= eval(PreIdWoVal)) {
                alert("this WorkOut should be greater than Previous value");
                $("#txt" + thisIdWO).val("");
                $("#txt" + thisIdWO).focus();
            }
            else if (thisIdVal != "" && thisIdWOval != "") {

                var sc = $("#spnCount").text() + "2";
                if (eval(sc) < eval(id[1])) {
                    var check = $("#spnCount").text();
                    check = check + "2";
                    check = eval(check) + 10;
                    if (eval(check) == eval(id[1])) {
                        var cc = eval(id[1]-1) + 10;
                        var ftxtid = "txt" + cc;
                        cc = eval(id[1]) + 10;
                        var stxtid = "txt" + cc;
                        $("#divWorkOuts").append('<div style="float: left; width: 60%;"><input onkeypress="return onlyNos(event,this);"   onblur="return WorkOutValidation(this);"  style="width: 50px;" id=' + ftxtid + ' value="" type="text" /></div><div style="float: left; width: 40%;"><input type="text" onkeypress="return isNumber(event)"  onblur=getnewrow(this);  id=' + stxtid + '  value="" style="width: 50px;" /></div>');
                        $("#" + ftxtid).focus();
                        var SpnCnt = eval($("#spnCount").text()) + 1;
                        $("#spnCount").text(SpnCnt);

                    }
                }

            }
            else {
                alert("please Enter value");
            }
        }
        function WorkOutValidation(a) {
            var id = $(a).attr('id').split('txt');
            var PreID = eval(id[1]) - eval(10);
            var thisIdVal = $(a).val();
            var PreIDVal = $("#txt" + PreID).val();
            if (eval(thisIdVal) <= eval(PreIDVal)) {
                alert("this WorkOut should be Less than Previous WorkOut");
                $(a).val("");
                return false;
            }
        }
     
        function getnewrowBWO(a) {
            var id = $(a).attr('id').split('txt');
            var PreID = eval(id[1]) - eval(1);
            var PrePreID = eval(id[1]) - eval(2);
            var IdTop = eval(id[1]) - eval(10);
            var thisIdVal = $(a).val();
            var PreIDVal = $("#txt" + PreID).val();
            var PrePreIDVal = $("#txt" + PrePreID).val();
            var IdTopVal = $("#txt" + IdTop).val();
            if (eval(PreIDVal) <= eval(PrePreIDVal)) {
                alert("this WorkOut should be Greater than Previous WorkOut");
                $(a).val("");
                $(a).focus();
            }
            else if (eval(id[1]) != 13 && eval(thisIdVal) >= eval(IdTopVal)) {
                alert("this Price should be Less than Previous Price");
                $(a).val("");
                $(a).focus();
            }
            else if (thisIdVal != "" && PreIDVal != "" && PrePreIDVal != "") {
                var sc = $("#spnCount").text() + "3";
                if (eval(sc) < eval(id[1])) {
                    var check = $("#spnCount").text();
                    check = check + "3";
                    check = eval(check) + 10;
                    if (eval(check) == eval(id[1])) {
                        var cc = eval(id[1]) + 8;
                        var ftxtid = "txt" + cc;
                        cc = eval(id[1]) + 9;
                        var stxtid = "txt" + cc;
                        cc = eval(id[1]) + 10;
                        var thtxtid = "txt" + cc;
                        $("#divWorkOuts").append('<div style="float: left; width: 60%;"><input onkeypress="return onlyNos(event,this);" onblur="return check1txtBWO(this);" type="text" id=' + ftxtid + ' value="" style="width: 50px;" />&nbsp;to&nbsp;<input onkeypress="return onlyNos(event,this);" onblur="return check2txtBWO(this);" style="width: 50px;" id=' + stxtid + ' value="" type="text" /></div><div style="float: left; width: 40%;"><input onkeypress="return isNumber(event)" onblur=getnewrowBWO(this); type="text" id=' + thtxtid + '  value="" style="width: 50px;" /></div>');
                        $("#" + ftxtid).focus();
                        var SpnCnt = eval($("#spnCount").text()) + 1;
                        $("#spnCount").text(SpnCnt);
                    }
                }

            }
            else {
                alert("please Enter value");
            }
        }
        function check2txtBWO(a) {
            var id = $(a).attr('id').split('txt');
            var PreID = eval(id[1]) - eval(1);
            var thisIdVal = $(a).val();
            var PreIDVal = $("#txt" + PreID).val();
            if (eval(thisIdVal) <= eval(PreIDVal)) {
                alert("this WorkOut should be Greater than Previous value");
                $(a).val("");
                $(a).focus();
            }

        }
        function check1txtBWO(a) {
            var id = $(a).attr('id').split('txt');
            var PreID = eval(id[1]) - eval(9);
            var thisIdVal = $(a).val();
            var PreIDVal = $("#txt" + PreID).val();
            if (eval(id[1]) != 11) {
                if (eval(thisIdVal) <= eval(PreIDVal)) {
                    alert("this WorkOut should be Greater than Previous value");
                    $(a).val("");
                    $(a).focus();
                }
            }
        }
       
        function SaveWorkOuts() {
            $('#DisableDiv').append('<div style=background-color:#5D6165;position:absolute;top:0;left:0;width:100%;height:100%;z-index:1001;-moz-opacity:0.8;opacity:.80;filter:alpha(opacity=80);><img src=../UIAssets/Inclub/Images/loaderAnim.gif style=background-color:Aqua;position:absolute;top:50%;left:44%;width:147px;height:36px;/></div>');

            if (document.getElementById('MainContent_rbtnWrkOutType_0').checked == true || document.getElementById('MainContent_rbtnWrkOutType_1').checked == true) {
                var StatusWO;
                if (document.getElementById('MainContent_cbActive').checked == true)
                    StatusWO = 1;
                else if (document.getElementById('MainContent_cbActive').checked == false)
                    StatusWO = 0;
                var QS = window.location.href.slice(window.location.href.indexOf('?') + 1).split('=');
                var QSplit = QS[1].split(',');
                if (QSplit[2] == 1) {
                    var len = $("#spnCount").text();
                    var Loop = "";
                    var LoopData;
                    var WOT;
                    if (document.getElementById('MainContent_rbtnWrkOutType_0').checked == true) {
                        WOT = "b";
                        for (var c = 0; c < eval(len) + 1; c++) {
                            var WOI1 = "txt" + eval(c + 1) + "1";
                            var WOI2 = "txt" + eval(c + 1) + "2";
                            var PI = "txt" + eval(c + 1) + "3";
                            var WO1 = $("#" + WOI1).val();
                            var WO2 = $("#" + WOI2).val();
                            var PV = $("#" + PI).val();
                            if (WO1 != "" && WO2 != "" && PV !== "") {
                                LoopData = WO1 + "^" + WO2 + "^" + PV;
                                if (Loop != "") {
                                    Loop = Loop + "^" + LoopData;
                                }
                                else if (Loop == "") {
                                    Loop = LoopData;
                                }
                            }
                        }
                    }
                    else if (document.getElementById('MainContent_rbtnWrkOutType_1').checked == true) {
                        WOT = "s";
                        for (var c = 0; c < eval(len) + 1; c++) {
                            var WOI = "txt" + eval(c + 1) + "1";
                            var PI = "txt" + eval(c + 1) + "2";
                            var WO = $("#" + WOI).val();
                            var PV = $("#" + PI).val();
                            if (WO != "" && PV !== "") {
                                LoopData = WO + "^" + PV;
                                if (Loop != "") {
                                    Loop = Loop + "^" + LoopData;
                                }
                                else if (Loop == "") {
                                    Loop = LoopData;
                                }
                            }
                        }
                    }
                 
                    var QS = window.location.href.slice(window.location.href.indexOf('?') + 1).split('=');
                    var QSplit = QS[1].split(',');
                  
                    if (eval(len) != 0) {
                        $.ajax({
                            type: "POST",
                            url: "EditCategory.aspx/InsertEditWorkOuts",
                            data: "{'CatId': '" + QSplit[0] + "','LoopData': '" + Loop + "','WOT': '" + WOT + "','Status': '" + StatusWO + "'}",
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function (data) {
                                alert("WorkOuts Inseted SucessFully");
                                $('#DisableDiv').html("");
                                location.href = "Category.aspx";
                            },
                            error: function (result) {
                                alert(" Error");
                            }
                        });
                    }
                    else {
                        alert("Please Enter WorkOuts");
                        $('#DisableDiv').html("");
                    }
                }
                else if (QSplit[2] == 2) {
                    var ToDo;
                    if (QSplit[3] == 1)
                        ToDo = "Insert";
                    else if (QSplit[3] == 0)
                        ToDo = "Update";
                    $.ajax({
                        type: "POST",
                        url: "EditCategory.aspx/FlexWorkOuts",
                        data: "{'CatId': '" + QSplit[0] + "','Rate': '" + $("#txtFixedPrice").val() + "','ToDo': '" + ToDo + "','Status': '" + StatusWO + "'}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (data) {
                            alert("WorkOuts Saved SucessFully");
                            $('#DisableDiv').html("");
                            location.href = "Category.aspx";
                        },
                        error: function (result) {
                            alert(" Error");
                        }
                    });
                }
            }
            else {
                alert("Please select Workouts Type");
                $('#DisableDiv').html("");
            }
        }
     
        function onlyNos(e, t) {
            try {
                if (window.event) {
                    var charCode = window.event.keyCode;
                }
                else if (e) {
                    var charCode = e.which;
                }
                else { return true; }
                if (charCode > 31 && (charCode < 48 || charCode > 57)) {
                    return false;
                }
                return true;
            }
            catch (err) {
                alert(err.Description);
            }
        }
        function isNumber(evt) {
            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode != 46 && charCode > 31
            && (charCode < 48 || charCode > 57))
                return false;
            return true;
        }

      
        function DeleteCat() {
            var QS = window.location.href.slice(window.location.href.indexOf('?') + 1).split('=');
            var QSplit = QS[1].split(',');
            var catid = QSplit[0];
            var conf = confirm("Are you sure to want to delete this Category.");
            if (conf == true) {
                alert("delete");
                $('#DisableDiv').append('<div style=background-color:#5D6165;position:absolute;top:0;left:0;width:100%;height:100%;z-index:1001;-moz-opacity:0.8;opacity:.80;filter:alpha(opacity=80);><img src=../UIAssets/Inclub/Images/loaderAnim.gif style=background-color:Aqua;position:absolute;top:50%;left:44%;width:147px;height:36px;/></div>');
                $.ajax({
                    type: "POST",
                    url: "EditCategory.aspx/DeleteCategory",
                    data: "{'CatId': '" + catid + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data) {
                        alert("Category Deletes Sucessfully");
                        $('#DisableDiv').html("");
                        location.href = "Category.aspx";
                    },
                    error: function (result) {
                        alert(" Error");
                    }
                });
            }
        }
    
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="featurecontent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
      <div id="DisableDiv"></div>

    <div class="con_bg2">
        <div class="con_bg">
            <div class="a_w">
                <div class="clear">
                    <table width="50%">
                          <tr>
                            <td>
                                <span>Category:</span>
                            </td>
                            <td>:
                            </td>
                            <td>
                                                       <input type="text" id="txtCatEdit" />
                         <span id="spnCount" style="width:5px;color:#c4c4c3;"></span>
                            </td>
                        </tr>
                          <tr>
                            <td>
                                <span>Active</span>
                            </td>
                            <td>:
                            </td>
                            <td>
                                <asp:CheckBox ID="cbActive" runat="server" Text="Active" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span>MemberShip Type</span>
                            </td>
                            <td>:
                            </td>
                            <td>
                               <%-- <asp:RadioButtonList runat="server" ID="rbtnPlanType" RepeatDirection="Horizontal">

                            <asp:ListItem Text="Flex" Value="0"></asp:ListItem>
                            <asp:ListItem Text="Fixed" Value="1"></asp:ListItem>
                        </asp:RadioButtonList>
                                <input type="text" id="txtMemberShipType" readonly="readonly" />--%>
                                <span id="spnMemberShipType"></span>
                            </td>
                        </tr>
                        <tr id="trWT">
                            <td>
                                <span>Select WorkOuts Type</span>
                            </td>
                            <td>:
                            </td>
                            <td>
                                <asp:RadioButtonList runat="server" ID="rbtnWrkOutType" RepeatDirection="Horizontal">
                                    <asp:ListItem Text="Between WorkOuts" Value="0"></asp:ListItem>
                                    <asp:ListItem Text="Serial WorkOuts" Value="1"></asp:ListItem>

                                </asp:RadioButtonList>
                            </td>
                        </tr>
                        <tr id="trWT1">
                            <td></td>
                            <td></td>
                            <td>
                                <div style="float: left; width: 50%; text-align: center;">
                                    WorkOut
                                </div>
                                <div style="float: left; width: 40%; text-align: center;">
                                    Rate
                                </div>
                            </td>
                        </tr>
                        <tr id="trFixedPrice">
                            <td>Rate</td>
                            <td>:</td>
                            <td>
                             <input type="text" id="txtFixedPrice" />
                            </td>
                        </tr>
                    </table>
                    <div id="divWT" style="float: left; width: 548px;">
                        <div style="float: left; width: 30%; text-align: center;">
                          s
                        </div>
                        <div id="divWorkOuts" style="float: left; width: 70%; text-align: center;">
                           <%-- <div style="float: left; width: 60%;"><input style="width: 50px;" type="text" /></div><div style="float: left; width: 40%;"><input type="text" style="width: 50px;" /></div>--%>

                        </div>
                    </div>
                    <div style="width:100%;float:left;text-align:center;">
                           <input type="button" id="btnSaveWorkOuts" class="btn_st_1" onclick="return SaveWorkOuts();"  value="Save" />
                          <input type="button" id="btnDelete" class="btn_st_1" value="Delete" onclick="DeleteCat()" />
                      <a href="Category.aspx">  <input type="button" id="Button1" class="btn_st_1"  value="Back" /></a>

                    </div>


                </div>
            </div>
        </div>
        <!--Content End-->
    </div>
</asp:Content>
Posted
Updated 30-Sep-14 2:56am
v2
Comments
Thanks7872 30-Sep-14 8:58am    
And what is the question? whether to use web method or not is already discussed at your previous post. No one will be going to analyze your code. Its your responsibility. If you find any issues doing the same,come back again.
vijaytaluri 30-Sep-14 9:13am    
Hi Rohan,
I am not asking you analyze the code. I am asking you, is there any mistakes or any suggestion regarding that code. So if are able to see my code means please give suggestion on that .

Web Methods is a good practice but it depends from Application and bussiness requirements. If you add multiple web methods to a single web service class, they will all have just a single URL making it simpler to use. On the client side, when you create a web reference, it will create a separate class for each web service, and than separate methods within each class, one for each web method. So, it's easier to work with in the client code, as well.
However your URL will always be exposed and hence available for DOS attack by anyone intended my making multiple hits.
You can "GOOGLE" Drawbacks and applications where it can be used and lastly your code is too big to comment on.
 
Share this answer
 
Hi Vijay,
Your question was not clear to me so I was telling you the scenario what I have faced while using WebMethods.

Its depend on the page behavior if you don't have query string in the page than its good.
I had faced this issue where I am opening a popup page and used query string where I also used the web methods. As page methods change your query string so I have to retain my query string value by using hidden fields.
 
Share this answer
 
v2

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