asp:Literal control null in user control

前端 未结 7 2061
南旧
南旧 2021-01-13 10:51

I\'ve a user control which contains asp:Literal.

7条回答
  •  孤独总比滥情好
    2021-01-13 11:09

    As mentioned in the answer by JerSchneid, if obj is null, you'll get that error. So, try doing it like this -

    internal void Setup(MyBusinessObject obj)
    {
        if(obj == null)
            MenuContainer.Visible = false;
        else
            MenuObject menu = MenuHelper.GetMenu(obj.State);
    }
    

    EDIT: I know you are getting an error on that line, but just try doing it like this. Or, else, remove the whole code and just keep the MenuContainer.Visible = false; line.

提交回复
热议问题