SharePoint User Group UK

Share the knowledge!

Welcome to SharePoint User Group UK Sign in | Join | Help
in
Home Blogs Forums Photos Files Roller

Displaying a custom ASP.Net page after a document is added to a library

Last post 12-03-2008, 7:27 PM by RichardPrice. 14 replies.
Sort Posts: Previous Next
  •  12-01-2008, 10:06 PM 15959

    Displaying a custom ASP.Net page after a document is added to a library

    Hi,

    Unfortunately I am slightly stuck!  I need to display a custom ASP.Net page to the user after they add a document to the document library, but I am unsure as to how to go about it - can you move the user to a custom page in an event handler, for example during ItemAdding or ItemAdded?

    What I am trying to do is have an automated process generate several values for the document, which the user will have to check over before they get added to the document in the library as metadata - hence the custom page, since the information has to be displayed to the end user for them to confirm it.

    Whats the best way to do this?

    Cheers
    Richard


  •  12-02-2008, 9:05 AM 15965 in reply to 15959

    Re: Displaying a custom ASP.Net page after a document is added to a library

    Hi,

    So long as there is at least one site column/content type which is a required field, you could edit/override the EditForm.aspx page and you wont need to worry about event handlers, etc.

    The document will have been uploaded to the library and the EditForm will handle whatever you need to do with assigning metadata to it. If you're goint ot run ASPX type code though, you may need to make the changes to enable scripts to run (google PageParserPath).


    Paul Leigh
    ---------------------------------------------
    Software Architect and a QuikR Microlight pilot in my spare time.
  •  12-02-2008, 2:16 PM 15980 in reply to 15965

    Re: Displaying a custom ASP.Net page after a document is added to a library

    That doesn't actually work for me, because we use Office 2007 here and required fields have their data entry forced within Word 2007/Excel 2007 *during* the save, rather than *after* the save.  In other words, you never see the EditForm.aspx page because you can't save the document without filling out the required fields in Word.


  •  12-02-2008, 2:29 PM 15982 in reply to 15959

    Re: Displaying a custom ASP.Net page after a document is added to a library

    Hi,

    Sounds to me like a custom ItemAdding Event handler is what you need - in it, I would perform the redirection using javascript - something along the lines of:

    string jscript = ("<SCRIPT language=\"JavaScript\" window.location = '" + _redirectUrl + "'</SCRIPT>");
    Context.Response.Write(jscript);

    then in your custom page generate your metadata values.



    Cheers,

    Nige
  •  12-02-2008, 3:01 PM 15987 in reply to 15982

    Re: Displaying a custom ASP.Net page after a document is added to a library

    AussieNigel wrote:
    Hi,

    Sounds to me like a custom ItemAdding Event handler is what you need - in it, I would perform the redirection using javascript - something along the lines of:

    string jscript = ("<SCRIPT language=\"JavaScript\" window.location = '" + _redirectUrl + "'</SCRIPT>");
    Context.Response.Write(jscript);

    then in your custom page generate your metadata values.


    Thanks for the response - I have already tried this, and it doesn't work, because there is no Context in the event handler, and getting one from HttpContext.Current doesn't work either.

    I am certain this is because there is no page infront of these actions, its all being triggered by the Office 2007 integration features and not a form, so theres nothing to redirect. 

    Ho hum.
  •  12-02-2008, 3:28 PM 15989 in reply to 15987

    Re: Displaying a custom ASP.Net page after a document is added to a library

    The only way I can think to do this then is using custom field control.

    By adding the logic you need into a custom field control (or several of them) you would be able to invoke some logic/process before the document is then saved. There are a few problems getting this to work in Word but you can get around them by ensuring the AllowBaseTypeRendering feild is set to TRUE


    Paul Leigh
    ---------------------------------------------
    Software Architect and a QuikR Microlight pilot in my spare time.
  •  12-02-2008, 4:30 PM 15991 in reply to 15959

    Re: Displaying a custom ASP.Net page after a document is added to a library

    Right - I see - bummer.

    This post proposes creating a HTTP Context in the constructor for your class that implements the event handler, but not sure how this would work when the handler is triggered from something like saving the document via word, or adding the document through a web folder - might be worth trying though I guess.

    I have never used the object, so know nothing about it, but would the SPUtility.TransferToSuccessPage be able to be used - I assume the string you pass in is the page you want to direct to (though I guess it could be a message displayed on a generic "success" page)

    Can see how what Paul is suggesting would work, though it seems a bit of a fudge, and (I assume) this custom column type would then become available to any user who customizes a list, which could cause problems.

    Cheers,

    Nige
  •  12-02-2008, 4:31 PM 15992 in reply to 15991

    Re: Displaying a custom ASP.Net page after a document is added to a library

    oops - this was the post: http://www.sharepointkings.com/2008/05/httpcontext-in-eventhandler.html


    Cheers,

    Nige
  •  12-02-2008, 4:54 PM 15995 in reply to 15992

    Re: Displaying a custom ASP.Net page after a document is added to a library

    AussieNigel wrote:
    oops - this was the post: http://www.sharepointkings.com/2008/05/httpcontext-in-eventhandler.html



    Thanks for that, that is actually one of the examples I am following, and it is still not working.  Works perfectly if all you are using is a standard List, but because the Document Library doesn't ever display the EditForm.aspx page, the redirect never seems to get caught by the context that the user is actually in - or in other words, the context accessible to the event handlers is completely separated from the context that the redirect needs in order to present the page to the user.

    Paul Leigh wrote:

    The only way I can think to do this then is using custom field control.

    By adding the logic you need into a custom field control (or several of them) you would be able to invoke some logic/process before the document is then saved. There are a few problems getting this to work in Word but you can get around them by ensuring the AllowBaseTypeRendering feild is set to TRUE



    The problem is, I actually need the document to be present in the document library, as I will be accessing it via the OpenXML SDK - also, the information I want to save is actually going into a separate list itself (Tasks).

    It seems very much like SharePoint is doing its damnest to get in the way :(


  •  12-02-2008, 5:17 PM 15996 in reply to 15995

    Re: Displaying a custom ASP.Net page after a document is added to a library

    A Fudge Nigel? The cheek :o)

    Ok, I see what you're trying to do now. How about solving this from another perspective? The Document Information Panel in Word is basically an Infopath form and I'm sure I've read that you can customise it. Might be worth a bit of googling?


    Paul Leigh
    ---------------------------------------------
    Software Architect and a QuikR Microlight pilot in my spare time.
  •  12-02-2008, 6:01 PM 15997 in reply to 15996

    Re: Displaying a custom ASP.Net page after a document is added to a library

    Paul Leigh wrote:

    A Fudge Nigel? The cheek :o)

    Ok, I see what you're trying to do now. How about solving this from another perspective? The Document Information Panel in Word is basically an Infopath form and I'm sure I've read that you can customise it. Might be worth a bit of googling?



    Hmmm,  I know what you are saying, but that sounds ... messy to me.  And at my level of coding (I'm a sysadmin, not a programmer!), I really don't want to be expanding the scope of potential issues that far.

    I think a custom workflow might suffice, as in start it when a new item is added, have the first step be to parse the document and display the information for verification, and the second step to be to add the tasks and carry out the notification.

    Thoughts?

    It really doesn't help that there isn't that much support from MS for developing SP solutions and features on XP :/  All the really cool stuff requires SP to be installed locally.

    Richard
  •  12-03-2008, 8:48 AM 16001 in reply to 15997

    Re: Displaying a custom ASP.Net page after a document is added to a library

    I don't think you're going to get away with it that easy. Workflows are not sensitive to the users context in the sense that there isn't a (sensible) way to start a workflow from a user initiated event and have it present a form to them. It can certainly fire of an email with a link to the form but it wouldn't be a seamless process.

    What you're trying to do is not what Workflows were designed for. You looking for an interuption in the normal processing, so event handlers or a modification/override of the input sequence is the way to go.

    All advice from MS is to develop on a Windows Server platform, XP & IE to be used for testing.


    Paul Leigh
    ---------------------------------------------
    Software Architect and a QuikR Microlight pilot in my spare time.
  •  12-03-2008, 9:01 AM 16003 in reply to 16001

    Re: Displaying a custom ASP.Net page after a document is added to a library

    Paul Leigh wrote:

    I don't think you're going to get away with it that easy. Workflows are not sensitive to the users context in the sense that there isn't a (sensible) way to start a workflow from a user initiated event and have it present a form to them. It can certainly fire of an email with a link to the form but it wouldn't be a seamless process.

    What you're trying to do is not what Workflows were designed for. You looking for an interuption in the normal processing, so event handlers or a modification/override of the input sequence is the way to go.

    Ahh ok, then I guess something that sounded easy isn't so easy :/  I shall look into doing what you suggested with the Word form.

    Paul Leigh wrote:

    All advice from MS is to develop on a Windows Server platform, XP & IE to be used for testing.



    Yeah, thats great advice from MS, until you come across something which requires XP for other tasks in your job description :/
  •  12-03-2008, 1:22 PM 16008 in reply to 16003

    Re: Displaying a custom ASP.Net page after a document is added to a library

    Richard,

    For development you're best using either Virtual PC or VMWare Player and a virtual server image containing Server 2k3,SharePoint and VS2005 or 2008.

    This lets you keep XP on your laptop/dekstop and just fire up the server image when you need to. It also adds the whole copying in a new virtual server when you break the original option..

    Paul


    www.myfatblog.co.uk
    twitter.com/@cimares
    MCTS: WSS 3.0
    MCTS: MOSS 2007
  •  12-03-2008, 7:27 PM 16014 in reply to 16008

    Re: Displaying a custom ASP.Net page after a document is added to a library

    Cimares wrote:

    Richard,

    For development you're best using either Virtual PC or VMWare Player and a virtual server image containing Server 2k3,SharePoint and VS2005 or 2008.

    This lets you keep XP on your laptop/dekstop and just fire up the server image when you need to. It also adds the whole copying in a new virtual server when you break the original option..

    Paul



    Yes, I've read that before.  Its all very well and good for people with fairly high end systems....
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems