Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have got a code:

if (sumaProcentow > 8) { e.Cell.Style.Add("background-color", "#FF0000"); e.Cell.CssClass = "dni_swiateczne"; } I wont when this code are true to auto post popap in the Sharepoint.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Grzegorz,

You can take a HiddenField on web part and set its value to true inside your code:

if (sumaProcentow > 8)
{
    HiddenField1.Value = "1";
}

Now in your web part in <script> write this:

<script type="text/javascript">

function callPopupOrNot()
{
   if (document.getElementById('<%= HiddenField1.ClientID %>').value == "1")
   {
        test();
    }
}

function test() { 
   var webUrl = "<%= SPContext.Current.Web.Url %>";
   SP.UI.ModalDialog.showModalDialog({ 
       url: webUrl + "/Lists/Announcements/NewForm.aspx", 
       title: "Add item", 
       allowMaximize: true, 
       showClose: true, 
       width: 800, 
       height: 600, 
       dialogReturnValueCallback: silentCallback }); 
 };

function silentCallback(dialogResult, returnValue) { } 

function refreshCallback(dialogResult, returnValue) { SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK); } } 

setTimeout(callPopupOrNot(),100);

</script>

Let me know if you have any questions! setTimeout is javascript function, which calls the callPopupOrNot function after 100 milliseconds...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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