Update web part properties programatically
Earlier in MOSS 2007, we used SPWebPartCollection objects to modify the web part properties through code. But now it is obsolete.
Now we have a new class called SPLimitedWebPartManager which we can use to do the same thing.
I have created a Visual web part with a button. On click of this button, we will make a page viewer web part show the www.google.com page.
Below shown is the code
The code will loop through all the web parts in the page where this web part is added and check for a web part with title Page Viewer. When a match is found, it will update the ContentLink property of it and reload the page for the changes to be observed.
You can use the above code for any web part by casting it to an appropriate type
Now we have a new class called SPLimitedWebPartManager which we can use to do the same thing.
I have created a Visual web part with a button. On click of this button, we will make a page viewer web part show the www.google.com page.
Below shown is the code
The code will loop through all the web parts in the page where this web part is added and check for a web part with title Page Viewer. When a match is found, it will update the ContentLink property of it and reload the page for the changes to be observed.
You can use the above code for any web part by casting it to an appropriate type
Borrow things from neighbors rentwagon.io is a online store. Find and check price for your desired products, choose the product comparing price,model,brand among thousands of items and get seller information
ReplyDelete