1

I have a boolean model variable who's value is supposed to be set to TRUE in order to perform a process on return back into the Controller.

It works absolutely fine on my local machine, but not on the remote web server.

Can somebody PLEASE inform me what I am missing? Below is the "proof of the pudding": The boolean value in quesion is "ShouldGeneratePdf";

MODEL:

namespace PDFConverterModel.ViewModels
{
    public partial class ViewModelTemplate_Guarantors
    {
        public ViewModelTemplate_Guarantors()
        {
            Templates = new List<PDFTemplate>(); 
            Guarantors = new List<tGuarantor>(); 
        } 

        public int SelectedTemplateId { get; set; }
        public List<PDFTemplate> Templates { get; set; }

        public int SelectedGuarantorId { get; set; }
        public List<tGuarantor> Guarantors { get; set; }

        public string LoanId { get; set; }
        public string DepartmentId { get; set; }
        public bool isRepeat { get; set; }
        public string ddlDept { get; set; }
        public string SelectedDeptText { get; set; }
        public string LoanTypeId { get; set; }
        public string LoanType { get; set; }

        public string Error { get; set; }
        public string ErrorT { get; set; }
        public string ErrorG { get; set; }
        public bool ShowGeneratePDFBtn { get; set; }
        public bool ShouldGeneratePdf { get; set; }
    }
}

MasterPage:

<!DOCTYPE html>
<html>
<head>
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/kendo/2012.2.913/kendo.common.min.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/kendo/2012.2.913/kendo.dataviz.min.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/kendo/2012.2.913/kendo.blueopal.min.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/modernizr-2.5.3.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/kendo/2012.2.913/kendo.all.min.js")"></script>
    <script src="@Url.Content("~/Scripts/kendo/2012.2.913/kendo.aspnetmvc.min.js")"></script>
</head>

<body>
    <div class="page">
        <header>
            <div id="title">
                <h1>BHG :: PDF Service Generator</h1>
            </div>
        </header>
        <section id="main">
            @RenderBody()
        </section>
        <footer>
        </footer>
    </div>
</body>
</html>

View:

@model PDFConverterModel.ViewModels.ViewModelTemplate_Guarantors

@using (Html.BeginForm("ProcessForm", "Home", new AjaxOptions { HttpMethod = "POST" }))
{ 
    <table style="width: 1000px">

        @Html.HiddenFor(x => x.ShouldGeneratePdf)

        <tr>
            <td>
                <img alt="BHG Logo" src="~/Images/logo.gif" />
            </td>
        </tr>
        <tr>
            <td>
                @(Html.Kendo().IntegerTextBox()
                  .Placeholder("Enter Loan Id")
                  .Name("LoanId")
                  .Format("{0:#######}")
                  .Value(Convert.ToInt32(Model.LoanId))
                )
            </td>
        </tr>
        <tr>
            <td>@Html.Label("Loan Type: ")
                @Html.DisplayFor(model => Model.LoanType)
            </td>
            <td>
                <label for="ddlDept">Department:</label>
                @(Html.Kendo().DropDownListFor(model => Model.ddlDept)
                            .Name("ddlDept")
                            .DataTextField("DepartmentName")
                            .DataValueField("DepartmentID")
                            .Events(e => e.Change("Refresh"))
                            .DataSource(source =>
                            {
                                source.Read(read =>
                                {
                                    read.Action("GetDepartments", "Home");
                                });
                            })
                            .Value(Model.ddlDept.ToString())
                    )
            </td>
        </tr>

        @if (Model.ShowGeneratePDFBtn == true)
        {
            if (Model.ErrorT == string.Empty)
            {
            <tr>
                <td>
                    <u><b>@Html.Label("Templates:")</b></u>
                </td>
            </tr>
            <tr>
                @for (int i = 0; i < Model.Templates.Count; i++)
                {  
                    <td>
                        @Html.CheckBoxFor(model => Model.Templates[i].IsChecked)
                        @Html.DisplayFor(model => Model.Templates[i].TemplateId)
                    </td> 
                }

            </tr>
            }
            else
            {
            <tr>
                <td>
                    <b>@Html.DisplayFor(model => Model.ErrorT)</b>
                </td>
            </tr>
            }

            if (Model.ErrorG == string.Empty)
            {
            <tr>
                <td>
                    <u><b>@Html.Label("Guarantors:")</b></u>
                </td>
            </tr>
            <tr>
                @for (int i = 0; i < Model.Guarantors.Count; i++)
                { 
                    <td>
                        @Html.CheckBoxFor(model => Model.Guarantors[i].isChecked)
                        @Html.DisplayFor(model => Model.Guarantors[i].GuarantorFirstName)&nbsp;@Html.DisplayFor(model => Model.Guarantors[i].GuarantorLastName)
                    </td> 
                }

            </tr>
            }
            else
            {
            <tr>
                <td>
                    <b>@Html.DisplayFor(model => Model.ErrorG)</b>
                </td>
            </tr>
            }
        }
        <tr>
            <td>
                <input type="submit" name="submitbutton" id="btnRefresh" value='Refresh' />
            </td>
            @if (Model.ShowGeneratePDFBtn == true)
            {
                <td>
                    <input type="submit" name="submitbutton" id="btnGeneratePDF" value='Generate PDF' />
                </td>
            }
        </tr>
        <tr>
            <td style="color: red; font: bold">
                @Model.Error
            </td>
        </tr>

    </table>
}

<script type="text/javascript">

    $('#btnRefresh').click(function () {
        Refresh();
    });

    function Refresh() {

        var LoanID = $("#LoanID").val();

        if (parseInt(LoanID) != 0) {
            $('#ShouldGeneratePdf').val(false)
            document.forms[0].submit();
        }
        else {
            alert("Please enter a LoanId");
        }
    }

    //$(function () {
    //    //DOM loaded
    //    $('#btnGeneratePDF').click(function () {
    //        DisableGeneratePDF();
    //        $('#ShouldGeneratePdf').val(true)
    //    });
    //});

    //function DisableGeneratePDF() {
    //    $('#btnGeneratePDF').attr("disabled", true);
    //    $('#btnRefresh').attr("disabled", true);
    //}


    $('#btnGeneratePDF').click(function () {
        alert("inside click function");
        DisableGeneratePDF();
        $('#ShouldGeneratePdf').val(true)
        tof = $('#ShouldGeneratePdf').val();
        alert("ShouldGeneratePdf set to " + tof);
    });

    function DisableGeneratePDF() {
        alert("begin DisableGeneratePDF function");
        $('#btnGeneratePDF').attr("disabled", true);
        $('#btnRefresh').attr("disabled", true);
        alert("end DisableGeneratePDF function");
    }

</script>

Controller:

[HttpPost]
        public ActionResult ProcessForm(string submitbutton, ViewModelTemplate_Guarantors model, FormCollection collection)

if ((submitbutton == "Refresh") || (submitbutton == null) && (model.ShouldGeneratePdf == false))
            {
}
else if ((submitbutton == "Generate PDF") || (model.ShouldGeneratePdf == true))
            {
}

The "Alerts" in the script above come out to exactly what they should be on the remote server. The last alert shows that the value of the bool variable is "true". However, when I do page source views of the hidden variable, below is the result.

The values of the hidden variable when the page loads and when the last alert button finishes are as follows:

My local machine:

The remote machine:

As you can see, the value on my machine is set to true when the process executes. However, on the remote machine, it is set to false where it then doesn't excute.

Why isn't the value in the model being returned as TRUE on the remote machine?

4

2 回答 2

0

这可能只是一个错字,但这条线

$('#ShouldGeneratePdf').val(true) 

没有收盘;

$('#ShouldGeneratePdf').val(true);
于 2012-11-09T04:56:45.070 回答
0

发现问题出在哪里......

使用 Fiddler,我能够确定该网站在 FireFox (v16.0.2) 下运行良好。我可以看到 Fiddler 中的值更改为 true,它将执行正常过程。

对于最新版本的 Chrome,它不起作用(v23.0.1271.84)。

如果使用 IE9,访问站点时会自动跳转到兼容模式。在 IE9 中,如果正在使用 Compatability View,则它不起作用。一旦我从兼容性视图更改回 IE9,它就可以正常工作了。在 IE9(IE8 和 IE7)之前,也不起作用。

微软和谷歌如何以及何时可以解决这些问题?

在此期间有什么建议可以解决这个问题吗?

我取消选中工具 | 下的框。兼容性查看设置并取消选中“以兼容模式显示 Intranet 站点”框。

所以,现在当我进入 IE 时,它会自动让我进入常规的 IE9 模式。

有人知道Chorme的类似设置吗?

于 2012-11-09T15:20:00.533 回答