title: Alertify.JS and ASP.NET: Call Javascript from Code-behind
body: <p>I have a question.</p>
  <p>I am now using the current version of Alertify.js found <a href="http://fabien-d.github.io/alertify.js/" rel="nofollow noreferrer">here</a>. I wanted to integrate it with my ASP.NET application. When I click the Save button from my Modal Dialog, it proceeds to the code-behind without problems. I've tried &quot;alert(&quot;Test&quot;);&quot; inside the  ScriptManager.RegisterClientScriptBlock and it does render.</p>
  <p>Now when I try to use my custom function located in one of the files I've added, it seems the script does not respond, i.e. Alertify does not show.</p>
  <p>Here is the JavaScript code from my custom JS file, my C# Code behind for that Save button, and the ASP.NET Page.</p>
  <p><strong>JS</strong></p>
  <pre><code>function callFeedbackMessage(inputType, inputText) {
      var inputFeedback = inputType;
  
      e.preventDefault();
  
      if (inputType == 'Error') {
          alertify.error(inputText);
          return false;
      }
      else if (inputType == 'Success') {
          alertify.success(inputText);
          return false;
      }
      else {
          alertify.log(inputText, &quot;&quot;, 10000);
          return false;
      }
  }
  </code></pre>
  <p><strong>C# Code Behind of lnkSave_Click</strong></p>
  <pre><code>    protected void lnkSave_Click(object sender, EventArgs e)
      {
          Category newCategory = new ProgrammersToolkitLibrary.BOM.Category();
          bool isSuccess = true;
  
          newCategory.CategoryName = txtCategoryName.Text;
          newCategory.Description = txtDescription.Text;
  
          isSuccess = CategoryController.CreateNewCategory(newCategory);
  
          if (isSuccess == true)
          {
              grdCategoriesList.DataBind();
              upCategoriesList.Update();
              ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), &quot;alert&quot;, &quot;callFeedbackMessage('Success', 'Okay');&quot;, true);
          }
          else
          {
          }
      }
  </code></pre>
  <p><strong>ASP.NET Page</strong></p>
  <pre><code>&lt;%@ Page Title=&quot;&quot; Language=&quot;C#&quot; MasterPageFile=&quot;~/Layout/Layout.Master&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;Category_List.aspx.cs&quot; Inherits=&quot;ProgrammersToolkit.Views.Maintenance.Categories.Category_List&quot; %&gt;
  &lt;asp:Content ID=&quot;Content1&quot; ContentPlaceHolderID=&quot;head&quot; runat=&quot;server&quot;&gt;&lt;/asp:Content&gt;
  &lt;asp:Content ID=&quot;Content2&quot; ContentPlaceHolderID=&quot;MainContent&quot; runat=&quot;server&quot;&gt;
  
      &lt;div style =&quot;text-align:left;&quot;&gt;
          &lt;h3&gt;Article Categories&lt;/h3&gt;
  
          &lt;div class=&quot;btn-group&quot;&gt;
              &lt;button class=&quot;btn btn-default&quot; data-toggle=&quot;modal&quot; data-target=&quot;#AddCategoryModal&quot;&gt;&lt;span class=&quot;glyphicon glyphicon-plus&quot;&gt;&lt;/span&gt; Add Category&lt;/button&gt;
              &lt;asp:LinkButton ID=&quot;LinkButton2&quot; runat=&quot;server&quot; CssClass=&quot;btn btn-default&quot;&gt;&lt;img src=&quot;../../../Layout/img/Icon_Excel.gif&quot; /&gt; Export to Excel&lt;/asp:LinkButton&gt;
              &lt;asp:LinkButton ID=&quot;LinkButton3&quot; runat=&quot;server&quot; CssClass=&quot;btn btn-default&quot;&gt;&lt;img src=&quot;../../../Layout/img/Icon_Excel.gif&quot; /&gt; Import from Excel&lt;/asp:LinkButton&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;br /&gt;&lt;br /&gt;
  
      &lt;div class=&quot;panel panel-default&quot;&gt;
  
        &lt;div class=&quot;panel-heading&quot;&gt;
          &lt;div class=&quot;row&quot;&gt;
              &lt;div class =&quot;col-lg-6&quot;&gt;
                  &lt;div class=&quot;input-group&quot;&gt;
                      &lt;asp:TextBox ID=&quot;txtSearch&quot; runat=&quot;server&quot; CssClass=&quot;form-control&quot;&gt;&lt;/asp:TextBox&gt;
  
                      &lt;span class=&quot;input-group-btn&quot;&gt;
                          &lt;asp:LinkButton ID=&quot;lnkSearch&quot; runat=&quot;server&quot; CssClass=&quot;btn btn-default&quot;&gt;Search&lt;/asp:LinkButton&gt;
                          &lt;asp:LinkButton ID=&quot;lnkReset&quot; runat=&quot;server&quot; CssClass=&quot;btn btn-default&quot;&gt;Reset&lt;/asp:LinkButton&gt;
                      &lt;/span&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class =&quot;col-lg-6&quot;&gt;&lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;panel-body&quot;&gt;
            &lt;asp:UpdatePanel ID=&quot;upCategoriesList&quot; runat=&quot;server&quot; UpdateMode=&quot;Conditional&quot;&gt;
                &lt;ContentTemplate&gt;
                  &lt;asp:GridView ID=&quot;grdCategoriesList&quot; runat=&quot;server&quot; CssClass = &quot;table table-hover table-responsive&quot; Width=&quot;100%&quot; 
                      DataSourceID=&quot;odsCategoriesList&quot; AllowPaging=&quot;true&quot; PageSize=&quot;10&quot; GridLines=&quot;None&quot; BorderStyle=&quot;NotSet&quot; BorderWidth=&quot;0px&quot;
                      AutoGenerateColumns=&quot;false&quot;&gt;
  
                      &lt;PagerSettings FirstPageText=&quot;&lt;&lt; First&quot; LastPageText=&quot;Last &gt;&gt;&quot; NextPageText=&quot;Next &gt;&quot;
                                          Position=&quot;Bottom&quot; PreviousPageText=&quot;&lt; Previous&quot; /&gt;
  
                      &lt;Columns&gt;                 
                          &lt;asp:TemplateField HeaderStyle-CssClass=&quot;input-group-addon&quot; ItemStyle-CssClass=&quot;input-group-addon&quot;&gt;
                              &lt;ItemTemplate&gt;
                                  &lt;asp:CheckBox ID=&quot;chkSelectItem&quot; runat=&quot;server&quot; /&gt;
                              &lt;/ItemTemplate&gt;
                              &lt;HeaderTemplate&gt;
                                  &lt;asp:CheckBox ID=&quot;chkSelectAll&quot; runat=&quot;server&quot; /&gt;
                              &lt;/HeaderTemplate&gt;
                          &lt;/asp:TemplateField&gt;
                          &lt;asp:TemplateField HeaderText = &quot;Category Name&quot; ItemStyle-HorizontalAlign=&quot;Left&quot;&gt;
                              &lt;ItemTemplate&gt;
                                  &lt;asp:LinkButton ID=&quot;lnkCategoryName&quot; runat=&quot;server&quot; OnCommand=&quot;lnkCategoryName_Command&quot; 
                                      CommandArgument='&lt;%# Eval(&quot;CategoryId&quot;) %&gt;' CommandName='&lt;%# Eval(&quot;CategoryName&quot;) %&gt;' 
                                      Text='&lt;%# Eval(&quot;CategoryName&quot;) %&gt;'&gt;&lt;/asp:LinkButton&gt;
                              &lt;/ItemTemplate&gt;
                          &lt;/asp:TemplateField&gt;
                          &lt;asp:BoundField DataField=&quot;Description&quot; HeaderText=&quot;Description&quot; ItemStyle-HorizontalAlign=&quot;Left&quot; /&gt;
                      &lt;/Columns&gt; 
  
                      &lt;PagerStyle HorizontalAlign=&quot;Right&quot; /&gt;
                  &lt;/asp:GridView&gt;
                &lt;/ContentTemplate&gt;
            &lt;/asp:UpdatePanel&gt;
      
        &lt;/div&gt;
    
        &lt;asp:ObjectDataSource ID=&quot;odsCategoriesList&quot; runat=&quot;server&quot; EnablePaging=&quot;True&quot; TypeName=&quot;ProgrammersToolkitLibrary.Controller.CategoryController&quot; 
            SelectMethod=&quot;GetListOfCategories&quot; SelectCountMethod=&quot;GetListOfCategoriesCount&quot;&gt;&lt;/asp:ObjectDataSource&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;modal fade&quot; id=&quot;AddCategoryModal&quot; tabindex=&quot;-1&quot; role=&quot;dialog&quot; aria-labelledby=&quot;myModalLabel&quot; aria-hidden=&quot;true&quot;&gt;
          &lt;div class=&quot;modal-dialog&quot;&gt;
          &lt;div class=&quot;modal-content&quot;&gt;
              &lt;div class=&quot;modal-header&quot;&gt;
              &lt;button type=&quot;button&quot; class=&quot;close&quot; data-dismiss=&quot;modal&quot; aria-hidden=&quot;true&quot;&gt;&amp;times;&lt;/button&gt;
              &lt;h4 class=&quot;modal-title&quot;&gt;Add New Category&lt;/h4&gt;
              &lt;/div&gt;
              &lt;div class=&quot;modal-body&quot;&gt;
                  &lt;table style=&quot;width:100%;text-align:left;&quot;&gt;
                      &lt;tr&gt;
                          &lt;td style = &quot;width: 30%;&quot;&gt;&lt;label for=&quot;txtCategoryName&quot;&gt;Category Name:&lt;/label&gt;&lt;/td&gt;
                          &lt;td&gt;
                              &lt;asp:TextBox ID=&quot;txtCategoryName&quot; runat=&quot;server&quot; CssClass=&quot;form-control&quot;&gt;&lt;/asp:TextBox&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td style = &quot;width:30%; vertical-align:text-top;&quot;&gt;&lt;label for=&quot;txtDescription&quot;&gt;Description:&lt;/label&gt;&lt;/td&gt;
                          &lt;td&gt;
                              &lt;asp:TextBox ID=&quot;txtDescription&quot; runat=&quot;server&quot; TextMode=&quot;MultiLine&quot; Rows=&quot;3&quot; CssClass=&quot;form-control&quot;&gt;&lt;/asp:TextBox&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/table&gt;
              &lt;/div&gt;
              &lt;div class=&quot;modal-footer&quot;&gt;
              &lt;asp:LinkButton ID=&quot;lnkSave&quot; runat=&quot;server&quot; CssClass=&quot;btn btn-primary&quot; OnClick=&quot;lnkSave_Click&quot; ClientIDMode=&quot;Static&quot;&gt;Save&lt;/asp:LinkButton&gt;
              &lt;button type=&quot;button&quot; class=&quot;btn btn-default&quot; data-dismiss=&quot;modal&quot;&gt;Close&lt;/button&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
  &lt;/asp:Content&gt;
  </code></pre>
  <p>Thank you.</p>
  <p>Ju-chan</p>