• 重写form里的action


            protected override void Render(System.Web.UI.HtmlTextWriter writer)
            
    {
                
    if(writer is System.Web.UI.Html32TextWriter)
                
    { writer=new FormFixerHtml32TextWriter(writer.InnerWriter);}
                
    else
                
    { writer=new FormFixerHtmlTextWriter(writer.InnerWriter);}
                
    base.Render(writer);
            }

            internal class FormFixerHtml32TextWriter:System.Web.UI.Html32TextWriter
            
    {
                
    private string _url;
                
    internal FormFixerHtml32TextWriter(TextWriter writer):base(writer)
                
    {
                    _url
    =HttpContext.Current.Request.RawUrl;
                }

                
    public override void WriteAttribute(string name, string value, bool fEncode)
                
    {
                    
    if(_url!=null&&string.Compare(name,"action",true)==0)
                    
    {
                        value
    =_url;
                    }

                    
    base.WriteAttribute (name, value, fEncode);
                }

            }


            
    internal class FormFixerHtmlTextWriter:System.Web.UI.HtmlTextWriter
            
    {
                
    private string _url;
                
    internal FormFixerHtmlTextWriter(TextWriter writer):base(writer)
                
    {
                    _url
    =HttpContext.Current.Request.RawUrl;
                }

                
    public override void WriteAttribute(string name, string value, bool fEncode)
                
    {
                    
    if(_url!=null&& string.Compare(name,"action",true)==0)
                    
    {
                        value
    =_url;
                    }

                    
                    
    base.WriteAttribute (name, value, fEncode);
                }

            }

  • 相关阅读:
    unittest详解(二) 跳过用例的执行(skip)
    Selenium获取input值的两种方法:WebElement.getAttribute("value")和WebElement.getText()
    python 函数参数的传递(参数带星号的说明) 元组传递 字典传递
    获取当前运行函数名称和类方法名称
    python中datetime模块中strftime/strptime函数
    面试题
    H5测试-缓存机制
    cp命令
    Java面试
    名词解释。。
  • 原文地址:https://www.cnblogs.com/songafeng/p/129012.html
Copyright © 2020-2023  润新知