2

GridView 内の一連の DropDownBox の値がリストの最初の値の項目にリセットされるという報告が時折ありました。

最終的に、ページがデータのレンダリング/読み込みを完了する前にユーザーが [保存] をクリックするというタイミングの問題まで突き止めました。ページの読み込みが速すぎるため、本番サーバーでは再現できますが、ローカルでは再現できません。

サーバー側でこれを検出して、返されたデータが無効であることを確認したり、ユーザーが設定していないデータの設定を停止したりするにはどうすればよいでしょうか?

4

2 に答える 2

1

ページがロードされている場合にのみ保存ボタンを有効にすることを考えましたか?

別の提案...ドロップダウンリストにはIDがありますか? ID なしで動的に生成されたコントロールで奇妙な問題が発生し、ポストバック後に間違った値が返されました...

于 2010-10-18T19:29:16.973 に答える
0

I had the same issue. Worked fine locally, but an occasional production user would somehow submit the page with partial form data.

From the logging I could see the HttpRequestFormVariables looked normal up to a point, and then the values became blank, which resulted in the site throwing an unhandled exception.

ctl00$MainContentPlaceHolder$foo$rptForm$ctl01$txtFormFieldId = 3815 ctl00$MainContentPlaceHolder$foo$rptForm$ctl02$txtFormFieldId = 3816 ctl00$MainContentPlaceHolder$foo$rptForm$ctl03$txtFormFieldId = 3817 ctl00$MainContentPlaceHolder$foo$rptForm$ctl04$txtFormFieldId = 3818 ctl00$MainContentPlaceHolder$foo$rptForm$ctl05$txtFormFieldId = ctl00$MainContentPlaceHolder$foo$rptForm$ctl05$txtFormFieldId =

The only way I've been able to reproduce it is to add some Javascript to the page to make it submit before fully loaded.

<script type="text/javascript">
    $("input[id$='btnSubmit']").click();
</script>

I suspect I will need to send btnSubmit back from the server in the disabled state and then enable it from Javascript after the page has completed loading.

if (btnSubmit.Enabled)
{
        btnSubmit.Enabled = false;
        string script = "$(document).ready(function() {$(\"input[id$='" + btnSubmit.ClientID + "']\").removeAttr('disabled');});";
        this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "EnableSubmitButton", script, true);
}
于 2012-08-29T03:55:20.567 に答える