C # Common class implementation read XML control asp.net control input information length

Source: Internet
Author: User
Tags foreach int size

Method body

using System;


using System.Xml;


using System.Configuration;


using System.Web;


using System.Web.UI.WebControls;


using System.Web.UI.HtmlControls;





namespace Xmlsize


{


public struct Strrestric


  {


public string Msgpage;


public string msgprompt;


public int size;


  }


public class Xmlrestrict


  {


public static strrestric res;


public xmlrestrict ()


    {


res.msgpage= "";


res.msgprompt= "";


res.size=0;


    }


public static Object Restrict (String xmlpathname,string nodeid,strrestric res)


    {


int nodenum=1;


String Path= "";


path =configurationsettings.appsettings.get (xmlpathname). ToString ();


path+= "Restrict.xml";


Try


      {


XmlDocument xmldoc=new XmlDocument ();


xmldoc.load (path);


xmlnodelist nodelist=xmldoc.selectsinglenode ("Tree"). ChildNodes;


foreach (XmlNode xn in nodelist)


        {


XmlElement xe= (xmlelement) xn;


if (XE. name== "Node")


          {


XmlNodeList Nls=xe. ChildNodes;


foreach (XmlNode xn1 in NLS)


            {


XmlElement xe2= (XmlElement) xn1;


if (xe2. name== "PageID")


              {


if (xe2. Innertext==nodeid)


                {


XmlNode xnchild= (XmlNode) Xe2;


XmlNode child=xnchild.parentnode.childnodes[nodenum+1];


XmlElement xechild= (XmlElement) child;


string Id=xechild.getattribute ("value");


int Pid=int. Parse (ID);


Res.msgpage=child. Innertext.tostring ();


res.msgprompt=xnchild.parentnode.childnodes[nodenum+2]. Innertext.tostring ();


Res.size=pid;


return res;


                }


break;


              }


            }


          }


        }


      }


Catch


      {}


return null;


    }

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.