Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Getting subsite url from aspx page in page-viewer webpart

  Date: Feb 20    Category: Sharepoint    Views: 1863

Hopefully, someone might be able to help me out here. I posted in
sharepoint stackexchange, but haven't come up with the right answer yet.

sharepoint.stackexchange.com/.../how-to-get-the-url-name-of-a\
-subsite-from-a-webpart

I have a custom aspx page (with code-behind) inside a page-viewer web part. I
need the aspx page to get the url of the subsite. It works after page load, but
when I interact with the aspx controls, it does its own postback and then can
only get the subsite of the aspx's page and not the sharepoint page. I have
explained it in detail on the link above.

Right now I have found a workaround using cookies, but it doesn't seem too
stable, and is a bit of a hack.

Share: 

 

4 Answers Found

 
Answer #1    Answered On: Feb 20    

Are you allowed to get it client-side with JavaScript? That would make
things easy.

 
Answer #2    Answered On: Feb 20    

Yes, I can use javascript, but then I have to get it back into aspx for the
control. I don't like the cookie workaround. I would have to have the aspx get
the results right from the javascript.

 
Answer #3    Answered On: Feb 20    

Help me understand this a bit better. You load the parent page, and then
the parent page loads the child page within a webpart (iframe), correct?

A few questions:

1) How many sites are going to use this parent page to load the Page View
WebPart?

2) When in the cycle does the child aspx need to know about the subsite?

3) Do you have the ability to add client-side code to the parent page?

 
Answer #4    Answered On: Feb 20    

I have about 120 sites that will use this technique. Here is what I
am thinking.

We have 120 chapels, each with their treasurer and pastor and coordinator. In
our portal there is a "chapels" page, and a particular subsite for each chapel.
All the users can view the chapels page, but only the particular ones can enter
a particular chapel subsite (sensitive information).

The treasurers have to upload certain accounting files, some of which are large.
I don't want to keep the large files (anywhere from 20mb to 500mb) in the SQL
database, and I also need file system access for those files from our LAN.

So my solution is to create an uploader control and put it in a page-viewer web
part. I only want to maintain one control, but I will have to put it into the
page-viewer webpart for each subsite. For an uploader, it is pretty basic -
just an aspx page and a code-behind.

So the control needs to know what subsite it is in. That is why it needs to
know the url that is displayed in the browser.

To answer your question then, by number:
1. There are 120 sites.
2. The child aspx needs to know the subsite as soon as it is loaded (no
problem) and *after* the user has uploaded a file - in case they choose to
upload that file again, and also so as to make a report to the user on the page.
3. Yes, I can add code anywhere. We are running SP 2010 Enterprise on our own
server. I can write code anywhere. My problem is that although I have
programming experience, I am just about ameteur in asp.net and sharepoint, both.
I like to learn however; it's just a matter of how much time I can spend on it.
But this is very important.

 




Tagged: