unable to update Label.HiddenFor() content after the ajax request

孤街浪徒 提交于 2019-12-25 03:19:11

问题


In my Asp.net MVC 2.0 web Application. I am using an Ajax form . After the Sucessful Ajax ,

I am mentioning update target ID to update content of page with out completely refreshing it.

In my View:

 <% using (Ajax.BeginForm("AjaxAdd", "Home", new AjaxOptions { OnSuccess = "Success", OnFailure = "Failed",UpdateTargetId = "VLD_EMP_ChangedOn"}))
                   { %>

           <%=Html.HiddenFor(Model => Model.CreatedOn)%>
           <%:Html.DisplayFor(Model => Model.CreatedOn)%>

I am returning a string from my controller to view to update CreatedOn with new value.

But, i was getting an Unknown runtime error

In MicrosoftMVCAjax.Debug.JS :

If (target) {
        switch (insertionMode) {
            case Sys.Mvc.InsertionMode.replace:
                target.innerHTML = content;  ==> Error Here
                break;
            case Sys.Mvc.InsertionMode.insertBefore:
                if (content && content.length > 0) {
                    target.innerHTML = content + target.innerHTML.trimStart();
                }
                break;
            case Sys.Mvc.InsertionMode.insertAfter:
                if (content && content.length > 0) {
                    target.innerHTML = target.innerHTML.trimEnd() + content;
                }
                break;
        }

The target i am getting is: CreatedOn

The Content is also not null and i am getting appropriate value.

But, it was still saying unknown runtime error

First of all I doubt, is it the right way to update an hidded content ?

If not..Please Specify appropriate way of doing it.

来源:https://stackoverflow.com/questions/19592707/unable-to-update-label-hiddenfor-content-after-the-ajax-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!