0

I have a problem on a SharePoint 2010 site. I have lists which contain Lookup fields. When I perform any action on the site that causes a custom dialogue to be displayed, the lookup fields become blank.

Here's what I mean:

Initially the lookup field is fine

Initially the lookup field is fine

Then we perform an action that results in a custom dialogue

Then we perform an action that results in a custom dialogue

After the dialogue is closed the lookup stays blank

After the dialogue is closed the lookup stays blank

It is important to note that the dialogue is coded to refresh the page when it is closed, but this does not get the lookup field to display correctly. A hard refresh does get it to display correctly though.

The dialogue is created using the ClientScriptManager.RegisterClientScriptBlock. The javascript is in the form:

@"<script type='text/javascript'>  
                        ExecuteOrDelayUntilScriptLoaded(function () {{
                            var options = {{
                                title: 'Title',
                                allowMaximize: false,
                                showClose: true,
                                autosize: true,
                                url: 'sample url here',
                                dialogReturnValueCallback: function(dialogResult) 
                                                            {{ 
                                                              SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK) 
                                                            }}
                            }};

                            SP.UI.ModalDialog.showModalDialog(options);
                        }}, 'sp.js')
                    </script>"

Any ideas??

0

Ok, I'm not sure why the Lookup fields blank out when a modal dialogue is displayed, but the following change solved this for me:

@"<script type='text/javascript'>  
                    ExecuteOrDelayUntilScriptLoaded(function () {{
                        var options = {{
                            title: 'Title',
                            allowMaximize: false,
                            showClose: true,
                            autosize: true,
                            url: 'sample url here',
                            dialogReturnValueCallback: function(dialogResult) 
                                                        {{ 
                                                          window.location = window.location.href;
                                                        }}
                        }};

                        SP.UI.ModalDialog.showModalDialog(options);
                    }}, 'sp.js')
                </script>"

All this does is redirects from the parent page to the parent page :). Effectively this is a refresh, but without the post data.

I am not sure if this is the best way to achieve this, if there are any other solutions out there that are better please let me know :)

Cheers!

  • As an addition to the above, the site is also blanking the Lookup fields when a sharepoint dialogue (like add new item) is diaplayed. So now I'm stumped, again. The above fixes things for my custom code, but not for built in functionality. Is this possibly due to SP1? – Mahendran Govender Jun 20 '13 at 13:37
  • This seems to be a permissions issue, the site admin adding a item into a list will have the lookup fields display fine, but anyone else adding into that list will result in the lookup fields being blank, until you refresh the page :'( – Mahendran Govender Jun 24 '13 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.