SharePoint 2007 get field value from page

702 Views Asked by At

Given a SharePoint page URL (http://server:8000/Pages/Default.aspx), how can I get value from the fields inside?

Do I have to use SPSite, SPWeb? Is there any direct way?

1

There are 1 best solutions below

2
On BEST ANSWER
 using (SPSite site = new SPSite(siteUrl))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        inheritedPage = web.GetFile(this.pageUrl);
                        //// Image_x0020_URL  
                        if (inheritedPage != null && inheritedPage.Item != null && inheritedPage.Item.Fields.ContainsField("Title")
                             && inheritedPage.Item.Fields.ContainsField("Url"))
                        {
                            return true;
                        }
                        else
                        {

                            return false;
                        }
                    }
                }

See the code above, checks if the page speicified by pageUrl contains the Title and Url fields.