How to do a viewstate in Javascript?

301 Views Asked by At

I'm new to Javascript,

I'm using the Javascript to get the file name from the FileUpload,

Here with my screenshot.

enter image description here

and my code

  $('#Q1DocPath').change(function () {

                var path = $(this).val();

                if (path != '' && path != null) {
                    var q = path.substring(path.lastIndexOf('\\') + 1);

                    $('#lblQ1Doc').html('<br/>' + '<p>' + q + '<a class="close"><font color="red">x</font><a>' + '</p>');

                }
            })

May I ask about How can I do it in ViewState? (Store and Load)

1

There are 1 best solutions below

0
On

What I understood from comments is that, you need to persist the value of q once it is assigned. Use localStorage to save the data, so that you can access it until get cleared by the user

For setting the value localStorage.setItem('path',q)

For getting the value localStorage.getItem('path')