代码之家  ›  专栏  ›  技术社区  ›  Ayo

jquery+mvc用户控件

  •  0
  • Ayo  · 技术社区  · 16 年前

    我要做的是将参数传递给用户控件视图,该视图将更新一个DIV标记,并基于隐藏的用户控件呈现新数据。我知道如何使用ajax.form()helper方法更新一个DIV标记,但是传递参数和更新部分控件是我无法做到的。我从来没有使用过jquery,并且查阅过一些关于如何在MVC中实现它的教程,但是我遇到了太多的死角,需要一些帮助来找出解决方案。我现在拥有的是这个,需要扩展它来更新用户控制视图。

    ASPX文件

    <form id="formParams">
        <input name="textSearch1" type="text" />
        <input name="textSearch2" type="text" />
        <input name="btnTest" type="submit" onclick="$get('recordsForm').onsubmit()" value="Click Me" />
    </form>
    <% using (Ajax.Form(
                "Records",
                "Search",
                null,
                new AjaxOptions
                {
                    UpdateTargetId = "records",
                    OnSuccess = @"function(sender, args){}",
                    HttpMethod = "GET"
                },
                new { @id = "recordsForm" }))
            {
            } 
        %>
        <div id="records">
            <img src="<%= Url.Content("~/Content/Images/load.gif") %>" alt="loading..." />
        </div>
    

    ACSX文件

    <%= ViewData["searchText1"].ToString()%> is the search you entered.
    

    控制器CS文件

    public ActionResult Records(string searchText1, string searchText2)
            {
    
                ViewData["searchText2"] = searchText2 + " Stop sucking at jQuery Ayo";
                ViewData["searchText1"] = searchText1;
    
    
                return View("Records");
    
    
            }
    
    1 回复  |  直到 13 年前
        1
  •  0
  •   Ayo    16 年前

    我知道了……哇,我所要做的就是将元素合并到Ajax表单中,而不是将它放在一个单独的表单之外。

    推荐文章