I've a webpart with a single asp:button, I've noticed that the Page.IsPostBack is not changing its state even though the user click on the button.

Also,I got an error when trying to using something like this Page.Request.Url

Message "Object reference not set to an instance of an object."

Have someone went through an issue like this?

The Client is a Sharepoint Online.

Local Environment: Sharepoint 2013 On Premise, Visual Web Part for Sandboxed solution

  • Does the page refresh when the user clicks on the button? – user19105 Feb 20 '15 at 13:07
  • Yes, it does refresh and the ispostBack is false. – leonardo Feb 20 '15 at 13:12
  • 1
    What logic is written in the button? Does it do basic stuff or does it redirect you to this page? If it's a redirect, then postback will be false. – user19105 Feb 20 '15 at 13:14
  • I have a webpart with a asp:button with an action and in this action there is no logic yet, I've just tested the if (Page.IsPostBack) and noticed that this is always returning false.. and it does not make any sense for me. – leonardo Feb 20 '15 at 13:16
  • Yea, that's weird. Have you tried the same web part as farm solution? Have you tried another web part in sandboxed solution? – user19105 Feb 20 '15 at 13:21

Try this:

  • Make Sure that 'EnbleViewState' property of your page or button is set to True.

  • Set button property UseSubmitBehavior="False"

|improve this answer|||||
  • I've tried this and unfortunately this change does not solved this weird issue. I was looking and I've found this link: support.cloudshare.com/hc/communities/public/questions/… but I do not know if this will resolve my problem. – leonardo Feb 20 '15 at 13:33
  • You've got SP on the same machine as AD as stated in the article? – user19105 Feb 20 '15 at 14:01
  • I have an AD on VM but it is not the same AD as my company uses. Do you think this may be a problem? I have other vm using the AD of my company and in this VM is working fine, but the problem is that we have the whole environment set on this one and the VM is very slow... – leonardo Feb 20 '15 at 14:17
  • When you retrieve data from a Null object you will get this error : "Object reference not set to an instance of an object". So,check for Null before retrieving. – Ronak Patel Feb 21 '15 at 4:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.