Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Page Viewer Web Part

  Asked By: Viral    Date: Mar 05    Category: Sharepoint    Views: 2536

I have a Page Viewer Web Part added to the portal server.

I would like to programatically assign the Content Link property of
a web part.

I have the following code...

SPSite my_Site_Lists = new SPSite
("http://server/sites/test/default.aspx") ;
SPWebCollection my_WebCollection_Lists =
my_Site_Lists.AllWebs;


foreach (SPWeb my_Site_WebLists in
my_WebCollection_Lists)
{

my_Site_WebLists.AllowUnsafeUpdates
= false;

SPWebPartCollection my_webparts =
my_Site_WebLists.GetWebPartCollection
("http://server/sites/test/pages/3.20Review.aspx",Storage.Shared);
foreach (WebPart mywebpart in
my_webparts)
{
if (mywebpart.Title
== "Review")
{
PageViewerWebPart
my_pg = (PageViewerWebPart)mywebpart;
my_pg.ContentLink
= "http://server/sites/test/pages/3.20Review.aspx/NewForm.aspx";
}

}

my_Site_WebLists.Update();

at the update method i get the following error:

"The security validation for this page is invalid. Click Back in
your Web browser, refresh the page, and try your operation again"

am I doing it the right way?

Share: 

 

6 Answers Found

 
Answer #1    Answered By: Bradford Norman     Answered On: Mar 05

I set the AllowUnsafeUpdates property  to true and it was working
just fine, but the ContentLink of the PageViewerWebpart would not
get update?

 
Answer #2    Answered By: Chandrabhan Baroova     Answered On: Mar 05

have you tried to add a call to the SaveChanges() method  on the
spWebPartCollection obj?

 
Answer #3    Answered By: Stacey Wilder     Answered On: Mar 05

I tried using the SaveChanges method  of the SPWebPartCollection, the GUID whcih
is displayed when i diaplay it to the secreen is
00000000-0000-0000-0000-000000000000 and also it gives an error  The operation
could not be completed because the web  Part is not a member of this collection.
function Ast_All_IstClick() { if (document.Form1.RadioButtonAllergy.checked
== true) { document.Form1.RadioButtonTypeIDiabetes.checked = false;
document.Form1.RadioButtonMultipleSclerosis.checked = false;
document.Form1.RadioButtonRheumatoidArthritis.checked = false;
document.Form1.RadioButtonLupusandRelated.checked = false;
document.Form1.RadioButtonPsoriarisandrelated.checked = false;
document.Form1.RadioButtonOther.checked = false;
document.Form1.RadioButtonKidneyTransplantation.checked = false;
document.Form1.RadioButtonLiverTransplantation.checked = false;
document.Form1.RadioButtonOtherSolid.checked = false; } else if
(document.Form1.RadioButtonAsthma.checked == true) {
document.Form1.RadioButtonTypeIDiabetes.checked = false;
document.Form1.RadioButtonMultipleSclerosis.checked = false;
document.Form1.RadioButtonRheumatoidArthritis.checked = false;
document.Form1.RadioButtonLupusandRelated.checked = false;
document.Form1.RadioButtonPsoriarisandrelated.checked = false;
document.Form1.RadioButtonOther.checked = false;
document.Form1.RadioButtonKidneyTransplantation.checked = false;
document.Form1.RadioButtonLiverTransplantation.checked = false;
document.Form1.RadioButtonOtherSolid.checked = false; } else if
(document.Form1.RadioButtonIslet.checked == true) {
document.Form1.RadioButtonTypeIDiabetes.checked = false;
document.Form1.RadioButtonMultipleSclerosis.checked = false;
document.Form1.RadioButtonRheumatoidArthritis.checked = false;
document.Form1.RadioButtonLupusandRelated.checked = false;
document.Form1.RadioButtonPsoriarisandrelated.checked = false;
document.Form1.RadioButtonOther.checked = false;
document.Form1.RadioButtonKidneyTransplantation.checked = false;
document.Form1.RadioButtonLiverTransplantation.checked = false;
document.Form1.RadioButtonOtherSolid.checked = false; } } function
openWindowOnClick() { if (document.Form1.RadioButtonTypeIDiabetes.checked ==
true) { document.Form1.RadioButtonAutoImmune.checked = true; } else if
(document.Form1.RadioButtonMultipleSclerosis.checked == true) {
document.Form1.RadioButtonAutoImmune.checked = true; } else if
(document.Form1.RadioButtonRheumatoidArthritis.checked == true) {
document.Form1.RadioButtonAutoImmune.checked = true; } else if
(document.Form1.RadioButtonLupusandRelated.checked == true) {
document.Form1.RadioButtonAutoImmune.checked = true; } else if
(document.Form1.RadioButtonPsoriarisandrelated.checked == true) {
document.Form1.RadioButtonAutoImmune.checked = true; } else if
(document.Form1.RadioButtonOther.checked == true) {
document.Form1.RadioButtonAutoImmune.checked = true; } else if
(document.Form1.RadioButtonKidneyTransplantation.checked == true) {
document.Form1.RadioButtonSolid.checked = true; } else if
(document.Form1.RadioButtonLiverTransplantation.checked == true) {
document.Form1.RadioButtonSolid.checked = true; } else if
(document.Form1.RadioButtonOtherSolid.checked == true) {
document.Form1.RadioButtonSolid.checked = true; } } is there anything
I am doing wrong?

Is my step 6 right?

1. SPWebPartCollection my_webparts = my_Site_WebLists.GetWebPartCollection
("http://<<server_name>>/sites/<<site_name>>/pages/3%20Review.aspx",Storage.Shar\
ed);



2. foreach (WebPart mywebpart in my_webparts)

3. {

4. if (mywebpart.Title == "Review Clinical Proposal")

5. {



6. PageViewerWebPart my_pg = (PageViewerWebPart)mywebpart;

7. System.Guid GU_ID = my_pg.ConnectionID;

8. Response.Write ("GU_ID:"+GU_ID.ToString()+"<br>");

9. my_pg.ContentLink =
"http://<<server_name>>/sites/<<site_name>>/Lists/%20Review/NewForm.aspx";

10. my_pg.ShouldSerializeContentLink();

11. my_webparts.SaveChanges(GU_ID);

12. }

13. }

 
Answer #4    Answered By: Francis Vargas     Answered On: Mar 05

I got the mistake...

I changed step 7 from

7. System.Guid GU_ID = my_pg.ConnectionID;

to

System.Guid GU_ID = mywebpart.StorageKey ;

but i keep getting this error?

The security  validation for this page  is invalid. Click Back in your Web
browser, refresh  the page, and try your operation  again

I have set AllowUnsafeUpdates of the web  to true?

any ideas?

 
Answer #5    Answered By: Tori Oconnor     Answered On: Mar 05

I am not sure at this time.I have not done exactly what you have done and I will
have to find time to try to copy this but that probably will not happen till
tonight at the earliest. Where is this code  located at and when is it being
called?

 
Answer #6    Answered By: Kristan Benjamin     Answered On: Mar 05

I have a button on a custom .aspx page  which is located in the _layouts
directory.

I am able to upadte list from the same page using other button placed on the
same .aspx page, I have this code  placed in the click  event of a button, this is
the first time I am trying to update  a web  part control.

 
Didn't find what you were looking for? Find more on Page Viewer Web Part Or get search suggestion and latest updates.




Tagged: