English 中文(简体)
ASP.NET MVC - Ajax.BeginForm - conditionsly popup式方言提交吗?
原标题:ASP.NET MVC - Ajax.BeginForm - conditionally pop-up modal dialog upon form submit?

我拥有几个县的投票控制。 它使用<代码>Ajax.BeginForm实施,该编码有一个隐蔽的领域,名称为vote 类型Hidden。 每次被点击表决国,都会改变TypeHidden的投票价值,以更新正在投什么票。 该表格提交给服务器,并报告使用<代码>的任何错误。 现在,我想利用我的 j印功能显示这一错误。

ModalDialog(button, text, fadeOut)

如何做到这一点? www.un.org/Depts/DGACM/index_spanish.htm 文本参数转至ModalDialog功能非常重要,是观点。

此前,没有必要,但我也公布了我使用的守则。

The javascript:

    <script  type = "text/javascript">
    var voteClickEnabled = true; 
    function voteClicked_Set(value) {
        var voteType = value;
        document.getElementById("voteTypeHidden").setAttribute("value", value); 
    }
    function voteBegin() {
        //alert("begin"); 
        if (voteClickEnabled == false) {
            return false;
        }
        else {
            voteClickEnabled = false;
            return true;
        }
    }
    function voteEnd() {
        //alert("end"); 
        voteClickEnabled = true;
    }

</script>

这里的观点是:

<div id  = "updateVotes">
<table>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>


Favorite : 
    <%=Html.Encode(ViewData["FavoriteCount"]) %>

<%//if(((int)ViewData["VoteBits"] & 1) == 0) 
{%>
    <% using (Ajax.BeginForm("Voting", "Vote", new {voted = ViewData["voted"], favorited = ViewData["favorited"], markedspam = ViewData["markedspam"],  VotingOnId = (long)ViewData["VotingOnId"], VoteOn = (int)ViewData["VoteOn"], num_votes = 0, num_favorite = (int?)ViewData["FavoriteCount"], sdg = (int?)ViewData["sdg"], category = (int?)ViewData["category"] }, new AjaxOptions { UpdateTargetId = "updateVotes", OnBegin = "voteBegin", OnComplete = "voteEnd"  }))
       {%>
        <%=Html.Hidden("voteTypeHidden", "temp", new { id = "voteTypeHidden" })%>
        <%if ((bool)ViewData["voted"] == false)
          { %>
        <%=Html.SubmitImage("voteButton", Url.Content("/Images/thumb_up.png"), new {value = "1", onclick = "voteClicked_Set(this.value)" })%>
        <%}
          else
          { %>
        <%=Html.SubmitImage("voteButton", Url.Content("/Images/cancel.png"), new { value = "2", onclick = "voteClicked_Set(this.value)" })%>
        <%} %>
         <%if ((bool)ViewData["favorited"] == false)
           { %>
        <%=Html.SubmitImage("voteButton", Url.Content("/Images/star_off_32.png"), new { value = "3", onclick = "voteClicked_Set(this.value)" })%>
         <%}
           else
           { %>
        <%=Html.SubmitImage("voteButton", Url.Content("/Images/star_32.png"), new { value = "4", onclick = "voteClicked_Set(this.value)" })%>
         <%} %>
         <%if ((bool)ViewData["markedspam"] == false)
           { %>
        <%=Html.SubmitImage("voteButton", Url.Content("/Images/error.png"), new { value = "5", onclick = "voteClicked_Set(this.value)" })%>
        <%}
           else
           { %>
        <%=Html.SubmitImage("voteButton", Url.Content("/Images/error_go.png"), new { value = "6", onclick = "voteClicked_Set(this.value)" })%>
        <%} %>
    <%}%>
<%}%>
<div id = "testingAjax">
</div>

<% if (!string.IsNullOrEmpty((string)ViewData["VoteError"])) { %>
<script type = "text/javascript">
    ModalDialog("testingAjax", "asd", false);
</script>
<%} %>
</div>
问题回答

仅是正常的html纽芬兰语,所有同级的图像,但你在html上称数据字“”

根据纽伦阶级是投票的思想,将一个隐蔽的散射点放在所谓的结果或反馈或类似的东西上:

$( .vote ).live("click",function(e){
    var voteType = $(this).attr("data-votetype");
    // do post to JsonResults
    $.ajax(
     url: "",
     type:"POST",
     data:{id:$("#idfield").val(),votetype:voteType},
     dataType:"json",
     success: function(data){
        $("#feedback").html(data.Message).show(); 

     },
     error:function(a,b,c){ $("#feedback").html("Error description: " + b).show(); }
    );
});

如果您愿意与亚克斯公司合作,你也可以与所设计的数据模型合作,而该数据模型则采用JSON respone,例如代码:

public class JsonResponseModel {
      public bool Success {get;set;}
      public string Message {get;set;}
}

public JsonResults CastVote(int id, int votetype){
      var model =  new JsonREsponseModel{ Success = false };
      // do code in try catch. change model to reflect success and message
      return Json(model);
}




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签