当前位置: 移动技术网 > IT编程>开发语言>.net > aspx不显示ViewState的实例

aspx不显示ViewState的实例

2017年12月12日  | 移动技术网IT编程  | 我要评论
复制代码 代码如下:system.io.stringwriter html = new system.io.stringwriter();   
复制代码 代码如下:

system.io.stringwriter html = new system.io.stringwriter();
             system.web.ui.htmltextwriter tw = new system.web.ui.htmltextwriter(html);
             base.render(tw);
             string temp = html.tostring();
             string s1 = string.empty, s2 = string.empty, s3 = string.empty, s4 = string.empty, s5 = string.empty, s6 = string.empty;
             int i = 0;
             int j = 0;

             i = temp.indexof("<form");
             if (i > 0)
             {
                 j = temp.indexof(">", i);
                 s1 = temp.substring(0, i);
                 s2 = temp.substring(j + 1, temp.length - j - 1);
             }

             i = s2.indexof("<input type=\"hidden\" name=\"__viewstate\" id=\"__viewstate\"");
             if (i > 0)
             {
                 j = s2.indexof(">", i);
                 s3 = s2.substring(0, i);
                 s4 = s2.substring(j + 1, s2.length - j - 1);
             }

             i = s4.indexof("<input type=\"hidden\" name=\"__eventvalidation\" id=\"__eventvalidation\"");
             if (i > 0)
             {
                 j = s4.indexof(">", i);
                 s5 = s4.substring(0, i);
                 s6 = s4.substring(j + 1, s4.length - j - 1);
                 temp = s1 + s3 + s5 + s6;
             }
             else
             {
                temp = s1 + s3 + s4;
             }
             temp = temp.replace("</form>", "");
             temp = temp.replace("\r\n", "");
             tw.close();
             response.write(temp);            

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网