Click here to Skip to main content
15,907,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
--scenario

I have a textbox in the layout page which is autocomplete. when something is selected in textbox it goes to different page. But the textbox becomes empty in next page.

-- So what I did I included the session.js plugin and included this part

PHP
if ($.session.get('Store') != null) {
                $('#StoreSearch').val($.session.get('Store'));
                $.session.set("Store", '');
            }





jquery



<script type="text/javascript">
        $(document).ready(function () {
      
            if ($.session.get('Store') != null) {
                $('#StoreSearch').val($.session.get('Store'));
                $.session.set("Store", '');
            }

            $("#StoreSearch").autocomplete({

                source: function (request, response) {
                    $.ajax({
                        url: '@Url.Action("GetAutoCompleteStoreDetails", "Home")',
                        data: { storeid: request.term },
                        mtype: "POST",
                        dataType: "json",
                        success: function (data) {
                            if (data.length > 0) {
                                response($.map(data, function (item) {
                                    return {
                                        value: item.StoreID + " " + item.StoreName,
                                        id: item.StoreID
                                    };
                                }))

                            }
                            else {
                                response({
                                    value: 'No Results found'
                                });
                            }
                        },
                        error: function () {
                            alert('Invalid Search');
                          
                        }

                    })
                },
                minLength: 1,
                select: function (event, ui) {
                    if (ui.item.value != 'No Results found') {
                        window.location.href = '@Url.Action("GetStoreSearchDetails", "DMSStatus")' + '?StoreID=' + ui.item.id 

                        //$('#StoreSearch').val(ui.item.id);
                        $.session.set("Store",  ui.item.value);
                        //session["store"] = ui.item.id;

                    }
                    else {

                        $('#StoreSearch').val('');

                    }
                }
            });

        })

    </script>



-- So this worked. The text box was not empty when I navigated to next page.
--But I have partial view part in the new page. So this doesn't go to layout page. So anything I do in partial view then text box should clear...but it doesnot clear..

Kindly suggest me an idea "how to persist the layout data in child views"
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