2016-06-20 4 views
0

私は、アプリケーションで標準のASP.NET WebForms検証コントロールを使用しています。私はちょっと気付いたことがあります。クライアント側の検証は、ある時点で動作しなくなったようです。 Webページは、しばらく赤でエラーを正しく示していますが、変更を失わせる不要なポストバックを引き起こします。Webフォーム上のクライアント側のフォームバリデータがエラー時にポストバックを引き起こしています

これは.net 4.5プロジェクトです。

私は、次のAppSettingています

<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />

また、causesValidationは、送信ボタンにtrueに設定されており、ValidationGroupが

答えて

0
などのボタンとバリデータに正しい値に設定されています

自分自身の質問に答えるためには、URLの書き換えを使用しているので、タグのレンダリングメソッドをオーバーライドし、副作用として、通常はサーバーサイドでレンダリングされるonclick属性をレンダリングしていなかったからです。

public class Form : System.Web.UI.HtmlControls.HtmlForm 
{ 
    /// <summary> 
    /// The RenderAttributes method adds the attributes to the rendered &lt;form&gt; tag. 
    /// We override this method so that the action attribute is not emitted. 
    /// </summary> 
    protected override void RenderAttributes(HtmlTextWriter writer) 
    { 
     // You cannot simply remove the form action as it seems to get rendered anyway 
     // but if you set it to the RawURL it will be the correct value on URL rewritten pages. 
     base.Attributes["action"] = HttpContext.Current.Request.RawUrl; 
     base.RenderAttributes(writer); 
    } 
} 

は、代わりに私は私のカスタム「ActionlessFormは」コントロールは、次のコードを使用するように変更しました

関連する問題