Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can go for a simpler way,</p> <ol> <li><p>Define the javascript function in the design/separate script file so that it accepts the name of item. eg. myFunction(itemName)</p></li> <li><p>And in your CS file, simply add a call to that function,</p> <p>if (IsNotAvailable) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "key", "myFunction('" + itemName + "') } }</p></li> </ol> <p>It will make things simpler and you would be able to confirm if this is a Javascript issue or a problem in how you are writing it through CS file.</p> <p><strong>Update:</strong></p> <p>Your first goal should be to make sure that your JS function is working for you, so before anything, add the following code in an empty html file and run it,</p> <pre><code>&lt;script type='text/javascript'&gt; ItemNotInStock('item'); function ItemNotInStock(itemName) { var message = "The following items are no longer in stock :" + itemName + ". Would you like to continue?"; if (confirm(message) == true) { location.href = "homePage.aspx"; } } </code></pre> <p></p> <p>If you redirect correctly then do what's mentioned below.</p> <p>Define the following javascript in your design file(tested it locally, working for me in chrome,)</p> <pre><code>&lt;script type='text/javascript'&gt; function ItemNotInStock(itemName) { var message = "The following items are no longer in stock :" + itemName + ". Would you like to continue?"; if (confirm(message) == true) { location.href = "homePage.aspx"; } } </code></pre> <p></p> <p>In your C# code, add following line</p> <pre><code>if (IsNotAvailable) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "key", string.Format("ItemNotInStock('{0}');", itemName); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload