0

ここに私の問題があります..

私はjqueryとmvc2を扱っています。チェックボックス、テキストボックス、ドロップダウンなどの入力コントロールで値を選択または書き込み、次のページに移動し、同じページに戻ります。チェックボックスをオンにするか、テキストボックスに値を入力する必要があります..できるかな

ページ間の入力制御値を維持します よろしくお願いします

    #region TableHeaderOnStart
    public string TableHeaderOnStart()
    {
        string TableHeaderValues = string.Empty;
        try
        {
        TableHeaderValues = TheadShipTo + "," + TheadCountry + "," + TheadNotes + "," + TheadShipStatus + "," + TheadStoreName + "," + TheadRSM;
        }
        catch (Exception ex)
        {
            TableHeaderValues = string.Empty;
            Logger.WriteToLog(Logger.LogType.Error, Constant.strmerchantname, Constant.struser, "OrderController.TableHeaderValues()", ex.Message, null, null);
        }
        return TableHeaderValues;
    }
    #endregion

    #region TableHeaders
    public void TableHeaders(bool ShipTo, bool Country, bool Notes, bool ShipStatus, bool StoreName, bool RSM)
    {
        TheadShipTo = ShipTo;
        TheadCountry = Country;
        TheadNotes = Notes;
        TheadShipStatus = ShipStatus;
        TheadStoreName = StoreName;
        TheadRSM = RSM;
    }
    #endregion

親ビューのコントローラーページの上記のコード...以下のコードは親ビュー用です..jqueryで....ほとんど私はそれを手に入れました....

     jQuery(document).ready(function ($) {
        $('#thetable1').tableScroll({ height: 100 });
        $('#table').tableScroll({ height: 100 });
        $('#thetable3').tableScroll({ height: 100 });


        var Url = '<%: Url.Action("TableHeaderOnStart", "Orders") %>';
        $.ajax({
            cache: false,
            type: "POST",
            url: Url,
            data: "",
            dataType: "HTML",
            success: function (data) {

                var Header = data.split(',');

                if (Header[0] == 'True') {
                    $('#jqTable tr').each(function () {
                        $(this).find("td:contains('Ship To')").show();
                        jQuery("#jqTable").showCol("Ship To")
                    });
                    $('#SHIPTO').attr('checked', true);
                }
                else {
                    $('#jqTable tr').each(function () {
                        $(this).find("td:contains('Ship To')").hide();
                        jQuery("#jqTable").hideCol("Ship To")
                    });
                    $('#SHIPTO').attr('checked', false);
                }

                if (Header[1] == 'True') {
                    $('#jqTable tr').each(function () {
                        $(this).find("td:contains('Country')").show();
                        jQuery("#jqTable").showCol("Country")
                    });
                    $('#COUNTRY').attr('checked', true);
                }
                else {
                    $('#jqTable tr').each(function () {
                        $(this).find("td:contains('Country')").hide();
                        jQuery("#jqTable").hideCol("Country")
                    });
                    $('#COUNTRY').attr('checked', false);
                }

                if (Header[2] == 'True') {
                    $('#jqTable tr').each(function () {
                        $(this).find("td:contains('Notes')").show();
                        jQuery("#jqTable").showCol("Notes")
                    });
                    $('#NOTES').attr('checked', true);
                }
                else {
                    $('#jqTable tr').each(function () {
                        $(this).find("td:contains('Notes')").hide();
                        jQuery("#jqTable").hideCol("Notes")
                    });
                    $('#NOTES').attr('checked', false);
                }

                if (Header[3] == 'True') {
                    $('#jqTable tr').each(function () {
                        $(this).find("td:contains('Ship Status')").show();
                        jQuery("#jqTable").showCol("Ship Status")
                    });
                    $('#SHIPSTATUS').attr('checked', true);
                }
                else {
                    $('#jqTable tr').each(function () {
                        $(this).find("td:contains('Ship Status')").hide();
                        jQuery("#jqTable").hideCol("Ship Status")
                    });
                    $('#SHIPSTATUS').attr('checked', false);
                }

                if (Header[4] == 'True') {
                    $('#jqTable tr').each(function () {
                        $(this).find("td:contains('Store Name')").show();
                        jQuery("#jqTable").showCol("Store Name")
                    });
                    $('#STORENAME').attr('checked', true);
                }
                else {
                    $('#jqTable tr').each(function () {
                        $(this).find("td:contains('Store Name')").hide();
                        jQuery("#jqTable").hideCol("Store Name")
                    });
                    $('#STORENAME').attr('checked', false);
                }

                if (Header[5] == 'True') {
                    $('#jqTable tr').each(function () {
                        $(this).find("td:contains('RequestedShipMethod')").show();
                        jQuery("#jqTable").showCol("RequestedShipMethod")
                    });
                    $('#RSM').attr('checked', true);
                }
                else {
                    $('#jqTable tr').each(function () {
                        $(this).find("td:contains('RequestedShipMethod')").hide();
                        jQuery("#jqTable").hideCol("RequestedShipMethod")
                    });
                    $('#RSM').attr('checked', false);
                }

            },
            error: function (xhr, ajaxOptions, thrownError) {
                if (xhr.status == 403) {
                    window.location.href = '<%: Url.Action( "SessionExpire", "Home" ) %>';
                }
            }
        });

        //window.onbeforeunload = function () {
        $(window).unload(function () {
            var SHIPTO = document.getElementById('SHIPTO').checked;
            var COUNTRY = document.getElementById('COUNTRY').checked;
            var NOTES = document.getElementById('NOTES').checked;
            var SHIPSTATUS = document.getElementById('SHIPSTATUS').checked;
            var STORENAME = document.getElementById('STORENAME').checked;
            var RSM = document.getElementById('RSM').checked;

            var Url = '<%: Url.Action("TableHeaders", "Orders") %>';
            $.ajax({
                cache: false,
                type: "POST",
                url: Url,
                data: "ShipTo=" + SHIPTO + "&Country=" + COUNTRY + "&Notes=" + NOTES + "&ShipStatus=" + SHIPSTATUS + "&StoreName=" + STORENAME + "&RSM=" + RSM,
                dataType: "HTML",
                success: function (data) {
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    if (xhr.status == 403) {
                        window.location.href = '<%: Url.Action( "SessionExpire", "Home" ) %>';
                    }
                }
            });
            return false;
        });
4

1 に答える 1

0

すでにレンダリングされたビューの「次へ」リンクをクリックすると、次のビューをレンダリングする別のアクション メソッドが呼び出されると思います。親ビューから次のビューに値を投稿し、テキストボックスの値、チェックボックスを親ビューのコントローラーアクションメソッドのセッション変数に保存してから、コントロールを次のビューのアクションメソッドに渡す必要があります...それをレンダリングします.. .

このビューで [戻る] ボタンを再度呼び出すと、親ビューのコントローラー アクション メソッドを呼び出します。これにより、既に存在するテキスト ボックス、チェックボックスの値を使用して親ビューがレンダリングされます。以前はセッション変数に保存されていました...

いくつかのコードを提供できる場合は、さらに支援するのは簡単です

于 2012-10-12T06:50:47.720 に答える