SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 2 down vote accepted


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")

function test() { 
   var webUrl = "<%= SPContext.Current.Web.Url %>";
       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); } } 



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


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.