title: Calling jQuery function from C# MVC
body: <p>How do I call Jquery function from C#? I have tried using registerStartupScript but I don't understand how it works still and it isn't working anyway. It doesn't enter jquery function at all</p>
  
  <pre><code>Page page = new Page();
  ScriptManager.RegisterStartupScript(page, this.GetType(), "script", "publishDialog();", true);
  </code></pre>
  
  <pre class="lang-js prettyprint-override"><code>function publishDialog() {
      $(".alert").dialog({
          modal: true,
      });
  }
  </code></pre>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div class="alert"&gt;
      You must be signed in to upload music
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Edit:</strong>
  If the user clicks on publish button and no files are selected then I want to display the jquery ui dialog popup box that tells them to select a file. I need this line <code>uploadedSongs.Count(x =&gt; x.IsSelected) == 0</code> to check if they have not selected a file. Is their anyway I can get this into my jquery function then?</p>
  
  <pre><code>[HttpPost]
       public ActionResult Publish(IEnumerable&lt;UploadedSong&gt; uploadedSongs)
          {
              Page page = new Page();
              if (uploadedSongs.Count(x =&gt; x.IsSelected) == 0)
              {
                  ScriptManager.RegisterStartupScript(page, this.GetType(), "script", "publishDialog();", true);
                  return View("../Users/UserProfile", uploadedSongs);
              }
              else
              {
                  return RedirectToAction("../Home/Index");
              }
          }
  </code></pre>