开发者

keep JavaScript array variable during post-back

How can I keep the values of ;ctrlIDhdnImageSourceArrayJs,ctrlIDhdnElementsArayJsHidden during a web page life-cycle...

"<script language = javascript>
                                            debugger;
                                            var ctrlIDhdnImageSourceArrayJs     = '" + this.hdnImageSourceArrayJs.ClientID + @"';
                                            var ctrlIDhdnElementsArayJsHidden   = '" + this.hdnElementsArayJsHidden.ClientID + @"';
                                            var loaderF = function getImagesData()
                                            {

                                                var fieldNamesList=[" + fieldNames + @"];
                                                return KrediKartUtils.LoadImagesData('0','" + KrediKartiRow.Row.SmartPenFormNo + @"',fieldNamesList,LoadImagesDataCallBack);        
                                            };


                                            function LoadImagesDataCallBack()
                                            {
                                            开发者_开发问答        if(images.length > 0) 
                                                    {
                                                        var numImages = 10; /*10 ar 10 ar göster*/
                                                        while(images.length > 0 && numImages-- > 0)
                                                        {
                                                            document.getElementById(elements.shift()).src =images.shift();

                                                        }
                                                       /* setTimeout(fetchImages, 1000); *//*1sn de bir*/
                                                    LoadImagesDataCallBack();
                                                    }

                                            }
                                            if('False' == '" + Page.IsPostBack.ToString() + @"')
                                            {

                                              var images=[" + imageSourceArrayJs + @"];
                                              var elements=[" + elementsArayJs + @"];  
                                              document.getElementById(ctrlIDhdnImageSourceArrayJs).value="""+imageSourceArrayJs+@""";
                                              document.getElementById(ctrlIDhdnElementsArayJsHidden).value="""+elementsArayJs+@""";  
                                              window.onload = loaderF;                                  
                                            }else{
                                                var images=[document.getElementById(ctrlIDhdnImageSourceArrayJs).value];
                                                var elements=[document.getElementById(ctrlIDhdnElementsArayJsHidden).value];                         
                                               LoadImagesDataCallBack();
                                            }

                                            </script>";


To keep any value or values during a new request, you will need to include those values with the request.

This means that for a GET, you need to include the values in the querystring

?myValue=1&myArray=1,2,3,4,5

And for a POST you need to append your values to the posted data (usually by placing them inside form fields during the "onsubmit" event.

You can then either process these server side and write out their value to the page or retrieve them from the document.location using JavaScript.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜