1

How to check current page URL address for null ID.. How to do this ?

This is my code, but not correct..

        private int id = -1;

        protected override void CreateChildControls()
        {
            try
            {
                if (SPContext.Current.ListItem != null)
                {
                    id = SPContext.Current.ListItem.ID;


                          MyLogic HERE.....
                 }
            }
         }
1

You can check it from QueryString in farm solution:

string id= Request.QueryString["ID"];

if (id != null)
{
//code goes here
}

In SandBoxed solution

string id= Page.Request.QueryString["ID"];

if (id != null)
{
//code goes here
}

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.