1public class Form : HtmlForm
2 {
3 protected override void RenderAttributes(HtmlTextWriter writer)
4 {
5 writer.WriteAttribute("name", Name);
6 base.Attributes.Remove("name");
7
8 writer.WriteAttribute("method", Method);
9 base.Attributes.Remove("method");
10
11 Attributes.Render(writer);
12
13 base.Attributes.Remove("action");
14
15 if (base.ID != null)
16 {
17 writer.WriteAttribute("id", ClientID);
18 }
19 }
20 }
目的主要是将Form中的Action去掉,让Url Rewrite在postback的时候能在IHttpModule中找到实际aspx文件,但在这样的环境下除了把Action去掉后也把验证控件的 onsubmit="if (!ValidatorOnSubmit()) return false;" 也去掉。2 {
3 protected override void RenderAttributes(HtmlTextWriter writer)
4 {
5 writer.WriteAttribute("name", Name);
6 base.Attributes.Remove("name");
7
8 writer.WriteAttribute("method", Method);
9 base.Attributes.Remove("method");
10
11 Attributes.Render(writer);
12
13 base.Attributes.Remove("action");
14
15 if (base.ID != null)
16 {
17 writer.WriteAttribute("id", ClientID);
18 }
19 }
20 }
想到一个笨的办法解决:
在postback的按钮,如
<asp:button id="btnOK" Runat="server" Text="确定" ></asp:button>
在按钮外端添加<span onclick="if (!ValidatorOnSubmit()){return false;}"><asp:button id="btnOK" Runat="server" Text="确定" ></asp:button></span>
即可在点击按钮前先通过 if(!ValidatorOnSubmit()) return false; 这个验证后再执行postback