aspx不显示ViewState的实例

发布时间:2022-04-16 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了aspx不显示ViewState的实例脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
复制代码 代码如下:

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);            

脚本宝典总结

以上是脚本宝典为你收集整理的aspx不显示ViewState的实例全部内容,希望文章能够帮你解决aspx不显示ViewState的实例所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: