Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <% using (Ajax.BeginForm("Update", "Description", new { id = Model.Id },
- new AjaxOptions
- {
- UpdateTargetId = "DescriptionDiv",
- HttpMethod = "post"
- },new {id ='AjaxForm' })) {%>
- Description:
- <%= Html.TextBox("Description", Model.Description) %><br />
- <input type="submit" value="save" />
- <% }%>
- $('form#AjaxForm').submit();
- <a href="#" onclick="$('form#AjaxForm').submit(); return false;">submit</a>
- $(function() {
- $('form#ajaxForm').find('a.submit-link').click( function() {
- $('form#ajaxForm').trigger('submit');
- }).show();
- }
- <% using (Ajax.BeginForm("Update", "Description", new { id = Model.Id },
- new AjaxOptions
- {
- UpdateTargetId = "DescriptionDiv",
- HttpMethod = "post"
- }, new { id = "ajaxForm" } )) {%>
- Description:
- <%= Html.TextBox("Description", Model.Description) %><br />
- <a href="#" class="submit-link" style="display: none;">Save</a>
- <noscript>
- <input type="submit" value="Save" />
- </noscript>
- <% } %>
- <div class="searchBar">
- <form action="<%= Url.Action ("SearchByName") %>" method="get" class="searchSubmitForm">
- <label for="projectName">Search:</label>
- <%= Html.TextBox ("projectName") %>
- <input class="submit" type="submit" value="Search" />
- </form>
- </div>
- <div id="projectList">
- <% Html.RenderPartial ("ProjectList", Model); %>
- </div>
- <script type="text/javascript">
- jQuery(document).ready(function() {
- jQuery("#projectName").keyup(function() {
- jQuery(".searchSubmitForm").submit();
- });
- jQuery(".searchSubmitForm").submit(function() {
- var options = {
- target : '#projectList'
- }
- jQuery(this).ajaxSubmit(options);
- return false;
- });
- // We remove the submit button here - good Javascript depreciation technique
- jQuery(".submit").remove();
- });
- </script>
- public ActionResult SearchByName (string projectName)
- {
- var service = Factory.GetService<IProjectService> ();
- var result = service.GetProjects (projectName);
- if (Request.IsAjaxRequest ())
- return PartialView ("ProjectList", result);
- else
- {
- TempData["Result"] = result;
- TempData["SearchCriteria"] = projectName;
- return RedirectToAction ("Index");
- }
- }
- public ActionResult Index ()
- {
- IQueryable<Project> projects;
- if (TempData["Result"] != null)
- projects = (IQueryable<Project>)TempData["Result"];
- else
- {
- var service = Factory.GetService<IProjectService> ();
- projects = service.GetProjects ();
- }
- ViewData["projectName"] = TempData["SearchCriteria"];
- return View (projects);
- }
- <div id="pnlSearch">
- <% using (Ajax.BeginForm("UserSearch", "Home", new AjaxOptions { UpdateTargetId = "pnlSearchResults" }, new { id="UserSearchForm" }))
- { %>
- UserType: <%: Html.DropDownList("FilterUserType", Model.UserTypes, "--", new { onchange = "$('#UserSearchForm').trigger('onsubmit');" })%>
- <% } %>
- </div>
- <div id="pnlSearchResults">
- <% Html.RenderPartial("UserSearchResults", Model); %>
- </div>
- <script type="text/javascript">
- $(function() {
- $('form#ajaxForm').submit(function(event) {
- eval($(this).attr('onsubmit')); return false;
- });
- $('form#ajaxForm').find('a.submit-link').click( function() {
- $'form#ajaxForm').submit();
- });
- }
- </script>
- <% using (Ajax.BeginForm("Update", "Description", new { id = Model.Id },
- new AjaxOptions
- {
- UpdateTargetId = "DescriptionDiv",
- HttpMethod = "post"
- }, new { id = "ajaxForm" } )) {%>
- Description:
- <%= Html.TextBox("Description", Model.Description) %><br />
- <a href="#" class="submit-link">Save</a>
- <% } %>
- <a href="#">
- <input type="submit" value="save" style="background: transparent none; border: 0px none; text-decoration: inherit; color: inherit; cursor: inherit" />
- </a>
- $('#detailsform').submit(function(e) {
- e.preventDefault();
- $.post($(this).attr("action"), $(this).serialize(), function(r) {
- $("#edit").html(r);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement