I wanted to use css file to my visual WebPart. Developing it in VS2012. Initially worked fine without .css after deployment. After following steps here, updated the .wsp. It is also working fine. But when I am going to add same Web Part on another page it showing error as Object reference not set to an instance of an object
In Code there is no null reference occurring while debugging.What should be the issue?
Also verified the css file is properly generated at
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\1033\STYLES\MailSenderV2
Edited: After digging it out it is found that in debug mode (by attaching w3 processes), when I Edit page in Sharepoint site it hits the
protected override void OnInit(EventArgs e)
Event of webpart and surprisingly it is making Page.Ispostback = true hence it is directly entering to the else part of condition.
if (!Page.IsPostBack)
And in this else part I am checked the value for drop down selected item. suddenly there is no values in drop down and returning null reference.Well I can change the logic here. But wondering why its making IsPostback as True in OnInit Event itself by hitting the Edit Page in Sharepoint site?