locked
Sharepoint 2007 Custom List Form Viewstate RRS feed

  • Question

  • I have created a Sharepoint 2007 list custom form with a number of asp:TextBox fields.  Some fields have Web Part connections that allow the field to be auto populated.  My problem is that Viewstate is only retaining values of the fields that have the Web Part connections but not the others. Can someone help me please?

    You can find my aspx code here: http://pastebin.com/43f0FK82

    Thank You


    • Edited by Makankan Wednesday, February 1, 2012 11:48 PM
    Wednesday, February 1, 2012 11:48 PM

Answers

  • Hi Makankan

     

    Thanks for your post. About your issue, you can use cookie to store your value. Following are some functions about operating the cookie use javascript:

    <script type="text/javascript" language="javascript">

    var name=name1;

    var value= document.getElementById(yourelementid).value;

    SetCookie(name, value);

        function SetCookie(name, value)//cookie name,cookie value

        {

            var Days = 30; //you can customize it

            var exp = new Date();    //new Date("December 31, 9998");

            exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);

            document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();

        }

        function getCookie(name)//get cookies       

        {

            var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));

            if (arr != null) return unescape(arr[2]); return null;

     

        }

        function delCookie(name)//delete cookie

        {

            var exp = new Date();

            exp.setTime(exp.getTime() - 1);

            var cval = getCookie(name);

            if (cval != null) document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();

        }

    </script>

     

    Find more information, please refer to the following link:

    http://social.msdn.microsoft.com/Forums/en/sharepointcustomization/thread/09c254ff-541c-46f8-a39e-fff7e91995a7

     

    Hope this can help you!

     

    Thanks,

    Lhan Han

    Monday, February 6, 2012 4:37 AM
    Moderator