Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I removed the AJAX.BeginForm an added Ajax.ActionLink which dosent submit the form .. instead it passes a single paramater to the controller which I need to check.. Here is the code..</p> <pre><code> &lt;% using (Html.BeginForm()) { %&gt; &lt;%: Html.ValidationSummary(true, "Account creation was unsuccessful. Please correct the errors and try again.") %&gt; &lt;fieldset&gt; &lt;div class="editor-label"&gt; &lt;%: Html.LabelFor(m =&gt; m.UserName) %&gt; &lt;/div&gt; &lt;div class="editor-field"&gt; &lt;%: Html.TextBoxFor(m =&gt; m.UserName) %&gt; &lt;%: Html.ValidationMessageFor(m =&gt; m.UserName) %&gt; &lt;/div&gt; &lt;%= Ajax.ActionLink("Checkavailability", "Checkavailability", new { UserName = "" }, new AjaxOptions { UpdateTargetId = "textEntered" }, new { id = "u" })%&gt; &lt;span id="textEntered"&gt;Nothing Entered&lt;/span&gt; &lt;p&gt; &lt;input type="submit" value="Register" /&gt; &lt;/p&gt; &lt;/fieldset&gt; &lt;% } %&gt; </code></pre> <p>Below is the jQuery which is used to set the parameters being passed</p> <pre><code> &lt;script type="text/javascript"&gt; $(document).ready(function () { $('#UserName').blur(function () { changeActionURL(); }); }); function changeActionURL() { if ($("#UserName").val() == "") { alert('Please enter your email to check availablity'); } else { var url = '&lt;%= new UrlHelper(ViewContext.RequestContext).Action("Checkavailability", "Account") %&gt;' + '?UserName=' + $("#UserName").val(); $("#u").attr('href', url); } } &lt;/script&gt; </code></pre> <p>the controller is..</p> <pre><code>public string Checkavailability(string UserName) { if (UserName != "Enter text" &amp;&amp; !String.IsNullOrEmpty(UserName)) { string userName = UserName.ToLower(); NorthwindEntities dbContext = new NorthwindEntities(); var query = from p in dbContext.Employees where p.FirstName.ToLower() == userName select p; IEnumerable&lt;Employee&gt; rec = query.ToList(); if (rec.Count() == 0) { return "You entered: \"" + UserName.ToString() + "\" available "; } else { return "You entered: \"" + UserName.ToString() + "\" already exists " + DateTime.Now.ToLongTimeString(); } } return String.Empty; } </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.
    3. 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