After using init method masterpage design time view is broken
I am using asp.net 4, .net 4 and masterpages. I added in the following code to my child page
Private Sub FoodChain_Init(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Init
MyBase.OnInit(e)
PopulateDropdowns()
HideQuestionDiv()
HideDropdowns()
End Sub
a开发者_StackOverflownd ran my app. The app runs fine but when I went back to the design view I now get an error saying "object reference not set to an instance". This is only during design time view and referencing the main place holder.
Is this a bug or am I missing something ? As I said the application runs fine and there are now issues during runtime.
Try putting all your databinding inside the following. (sorry about the c# code). I think it is Me.DesignMode
in VB.
if (!this.DesignMode)
{
PopulateDropdowns();
HideQuestionDiv();
HideDropdowns();
}
I'm not sure if this works correctly for nested user controls but worth a try. Note that this won't work inside a constructor, only other events.
MSDN here.
精彩评论