ID generation for HTML elements in ASP.NET MVC

后端 未结 4 977
刺人心
刺人心 2021-02-19 08:08

I need to generate unique identifiers for html elements in asp.net mvc application. In classic asp.net i could use

%>
         


        
4条回答
  •  花落未央
    2021-02-19 08:23

    May be this draft code help you:

    static class MyIdGenerator
    {
        public static int NextID()
        {
            static int _id = 0;
            return _id++;
        }
    }
    

    With static counter every call NextID() will return next Id;

提交回复
热议问题