--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
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
$.session.set("Store", ui.item.value);
}
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"