title: Showing pop up messagebox in aspx.cs file - Visual Studio 2015
body: <p>So I have a web page with a list of products.  Next to each product is a hyperlink that the user clicks to generate a Word document and is available for the user to view.  Each product has an ID, sizes, etc...  </p>
  
  <p>I have code that executes in the aspx.cs code behind and a try-catch block that checks to see if the selected product has sizes.  If the product doesn't have any sizes then I want a pop-up messagebox to appear to alert the user that the sizes have not been recorded for the product yet and it cannot generate the document.</p>
  
  <p>My question is, how can I accomplish this?  I have tried the Response.Write(...) function and the Page.ClientScript.RegisterStartupScript(...) function.  Both build fine and execute but no pop-up message.  I know I've used the Response.Write() function before and it's worked in VS2013 but doesn't seem to work in VS2015.</p>
  
  <p>Below is my code.  Any help/suggestions are appreciated.</p>
  
  <pre><code>    //Alert the user to fix the data if the parent sizes are missing from the Sizes column in ProductMart
      try
      {
          //This is set to null to execute Catch block
          parentSizeList = null;
          pSizes = parentSizeList.Split(',');
          foreach (var p in pSizes)
              parentSizes.Add(p);
      }
      catch 
      {
          Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('TEST');", true);
  
          Response.Write("&lt;script type=\"text/javascript\"&gt;alert('The Measurement Sizes are missing in the Product Mart for the parent product. " + 
              " Please fix the data for Pack Number " + product.PackNumber + " to print inspection document');&lt;/script&gt;");
      }
  </code></pre>