小编Ama*_*lla的帖子

如何在点击Ajax.Actionlink上刷新多个部分视图

我在我的视图上使用多个部分视图.在左侧我有一些链接按钮.

在中间我有2个局部视图让我们假设Up和Down我能够更新Up partialview现在我想更新Down部分视图点击同一个链接按钮

我只能在Ajax.ActionLink按钮中发送一个UpdateTargetID,但我想更新2 Partialview一个同一个按钮的clcik.

1)有没有办法可以在Ajax.ActionLink中传递多个UpdateTargetID或2)我可以在Home Controller中返回多个局部视图或者你建议的任何其他方式请回复我

谢谢大家回复让我告诉你我做了什么,以便在单击时刷新多个局部视图这是我用来点击的动作链接在这里我使用此Action链接的OnSucess函数来更新,此Action链接是部分视图

                 <%= Ajax.ActionLink("Select", "Employee", new { Id = Employee.EmployeeID }, new AjaxOptions { UpdateTargetId = "EmployeeDiv", HttpMethod = "Post", OnSuccess = "function(){EmployeeHistory(-2," + Employee.EmployeeID.ToString() + ");}" })%>
Run Code Online (Sandbox Code Playgroud)

这是我从局部视图调用的javascript

 function  EmployeeHistory(EmployeeID) {
    var url = '<%= Url.Action("PartialviewAction", "ControllerName") %>'
    $('#PartialviewDiv1').load(url, { Id: EmployeeID });
    var url1 = '<%= Url.Action("PartialviewAction", "ControllerName") %>'
    $('#PartialviewDiv2').load(url1, { Id: EmployeeID });

}
Run Code Online (Sandbox Code Playgroud)

这两个div在索引视图中,我想更新

        <div id="Paritalview div1"><% Html.RenderPartial("PartialViewname1"); %></div>
        <div id="Paritalview div2"><% Html.RenderPartial("PartialViewname2"); %></div>
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc asp.net-ajax asp.net-mvc-3

15
推荐指数
1
解决办法
1万
查看次数

从控制器中的formcollection中找到隐藏字段的值

我在我的视图中使用隐藏字段,它保存了活动标签索引的一些值现在我想要控制器中隐藏字段的值我使用提交按钮提交.

 public ActionResult Index(FormCollection frm)
    {     var value = frm["HiddenName"];
 }
Run Code Online (Sandbox Code Playgroud)

我提交表单并使用FormCollection来获取值但是当找到隐藏字段的值时我总是给我空白值,我已经检查过使用页面源代码它有一些价值

asp.net-mvc asp.net-mvc-3

4
推荐指数
1
解决办法
8189
查看次数

显示javascript警报消息时,窗口背景变为灰色

我正在使用一些服务器端验证,如果有任何问题,我会使用javascript显示弹出消息

  page.ClientScript.RegisterClientScriptBlock
Run Code Online (Sandbox Code Playgroud)

但是当我的消息显示时,窗口的背景变为灰色.

任何人都可以帮助我摆脱这个灰色的窗口

       public static class Alert
{

/// <summary>
/// Shows a client-side JavaScript alert in the browser.
/// </summary>
/// <param name="message">The message to appear in the alert.</param>
public static void Show(string message)
{
    // Cleans the message to allow single quotation marks
    string cleanMessage = message.Replace("'", "\\'");
    string script = "<script type=\"text/javascript\">alert('" + cleanMessage + "');</script>";

    // Gets the executing web page
    Page page = HttpContext.Current.CurrentHandler as Page;

    // Checks if the handler is a Page …
Run Code Online (Sandbox Code Playgroud)

javascript asp.net

0
推荐指数
1
解决办法
959
查看次数