Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

Are you using any QueryString with ID parameter??

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

share|improve this answer
    
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. –  cyberpine Sep 7 '12 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. –  cyberpine Sep 7 '12 at 23:30
add comment

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;
    }
}
share|improve this answer
    
You don't need to reset AllowUnsafeUpdates on SPWeb you're disposing. AllowUnsageUpdates is not persisted anywhere, but set by constructor. –  Per Jakobsen Sep 8 '12 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. –  cyberpine Sep 10 '12 at 14:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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