Required Property in Custom ASP .NET Control

血红的双手。 提交于 2019-12-05 16:33:32

Thats quite simple, on page load you can check if the property has some value or not. You can check it for Null or Empty case depending on your property type. like if i have this

private string _someString;
    public string SomeString
    {
        get { return _someString; }
        set { _someString = value; }
    }

On page_load event i will check if

if(_someString != null && _someString != "")
{ 
    String message = "Missing someString property";
    isAllPropertySet = false; //This is boolean variable that will decide whether any property is not left un-initialised
}

All The Best.

and finally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!