2

If I button post one sharePoint site page to a page on another I get

This Page has been modified since you opened it. You must open the page again.
Refresh

I have a webpart page with an asp.net button that is posting to page on another site on the same farm. That page is update a list item back on the original site. I'm doing it this way because I want to share the updating page with many other sites/solutions.

I'm passing no query strings. And the problem occurs on post to the second page. I have inline C# as follows.

I can't say for certain this code was ever working without the error to refresh. But Im pretty sure it was.

It asks for the refresh and then the update works.

protected override void OnLoad(EventArgs e)
{

try{
using (SPSite siteCollection = new SPSite("http://mysite/lists/mylist"))
{
    SPWeb web = siteCollection.OpenWeb();
    web.AllowUnsafeUpdates = true;
    SPList AC = web.GetList("http://mysite/lists/mylists");
    SPListItem oListItem = AC.GetItemById(1);
    oListItem["Status"] = "t2";
    oListItem.Update();
}
}
 catch (Exception ex)
 {
  Response.Write(ex.Message.ToString());
 }

On the from button calling side:

<asp:Button runat="server" Text="Job t3 Completed" id="complete" /></asp:Content>

with inline C# block

protected override void OnLoad(EventArgs e)
  {
     base.OnLoad(e);
        complete.PostBackUrl="https://........../t3.aspx";
    }

UPDATE: 9/10/202 1:155.. I just tested this with two basic aspx pages on both SharePoint sites. one with a button the other no code and still get the error. The postback URL having no querystring - It still gives me the error. I then button to aspx page on my desktop (non SharePoint) and do not get the error and request for refresh. Apparently, it's because I'm doing the postback from SharePoint? I've the javascript and directive changes suggested on on other sites with no luck.

1

2 Answers 2

1

Are you using any QueryString with ID parameter??

If yes, then change to it something else. Hope this helps :)

2
  • well I was and I thought you were correct since this has actually happened to me before. But apparently it's something else.. I updated my question.
    – Hell.Bent
    Commented Sep 7, 2012 at 23:23
  • Also, I was response.redirecting back, but that is apparently not where the problem is.. it's in a post from a button.
    – Hell.Bent
    Commented Sep 7, 2012 at 23:30
0

Fist of all you have to dispose SPWeb Object, also I recommend you to set back AllowUnsafeUpdates value:

Using(SPWeb web = siteCollection.OpenWeb())
{
    bool updates = web.AllowUnsafeUpdates;
    try
    {
         web.AllowUnsafeUpdates = true;
         SPList AC = web.GetList("http://mysite/lists/mylists");
         SPListItem oListItem = AC.GetItemById(1);
         oListItem["Status"] = "t2";
         oListItem.Update();
    }
    finally
    {
         web.AllowUnsafeUpdates = updates;
    }
}
2
  • 1
    You don't need to reset AllowUnsafeUpdates on SPWeb you're disposing. AllowUnsageUpdates is not persisted anywhere, but set by constructor. Commented Sep 8, 2012 at 17:14
  • I tested these changes.. they work and might help, but they do not address the error refresh issue. Could my problem be on the button postbackside? When I call the page directly it never asks for a refresh. I've updated my question with the button code.
    – Hell.Bent
    Commented Sep 10, 2012 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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