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

I'm building a system that shows a list's NewForm.aspx to an anonymous website visitor, which they can complete and submit. The URL to the form includes "?source=/_layouts/blah.aspx", so after the list has been updated with a new item, this blah.aspx page is called and can do other operations.

My question is, on blah.aspx, how can I get the values of the fields submitted as part of the form?

e.g.

  1. My list "QMKevin-List" has 3 fields: Title (text(, Email (text), OptOut (checkbox)
  2. NewForm.aspx shows these 3 fields, which I fill in and then I submit the form
  3. QMKevin-List is updated with a new list item
  4. /_layouts/blah.aspx is called, and let's say I want to send an email to whoever filled out the form

from blah.aspx, how can I get the email address of whoever completed the form? remember, this form is shown to anonymous visitors to my site, so they are not logged in (no SPContext.Current.User...)

Also, if blah.aspx wanted to update the list item, is there any way to get the item.id of the newly created item, so that I know exactly which item to update? this is in case someone complete the form twice with the same info.. I need that unique identifier so I know which item to update.

share|improve this question
    
Is this a totally custom solution or are you trying to stick with Out of the Box features? Which version of SharePoint are you using? Does the user need to interact more with blah.aspx? –  Panter Oct 25 '11 at 4:08
    
It's not a totally custom solution, but it is a custom form for a list, and is a custom processing page (blah.aspx) that the user ends up at. I'm using SharePoint Server 2010 (sorry, I should have mentioned that). No, the user doesn't need to interact with blah.aspx, but I need to use the values entered into the form and saved to the list, when blah.aspx is loaded. –  QMKevin Oct 25 '11 at 12:26

1 Answer 1

up vote 1 down vote accepted

In the code-behind of the form you are allowed a lot of diffent ways to store temporary data (http://msdn.microsoft.com/en-us/library/75x4ha6s.aspx) You could also write to database,...

In your case I would use the session state:

Application state is a global storage mechanism that is accessible from all pages in the Web application. Thus, application state is useful for storing information that needs to be maintained between server round trips and between requests for pages.

Session state is similar to application state, except that it is scoped to the current browser session. If different users are using your application, each user session will have a different session state. In addition, if a user leaves your application and then returns later, the second user session will have a different session state from the first.

Example:

Store in NewForm.aspx:

Session.Contents["Email"] = "this.is.my@email.com";

Get value in blah.aspx:

string email = Session.Contents["Email"];

For more info, see
Msdn session state

share|improve this answer
    
Thanks for that, Ruben. I ended up using JavaScript to add values to the "source" URL, which I can then use to identify the newly created list item. Similar to your approach, in that passing info can then be used either directly on blah.aspx, or can be used to identify the list item.. just using a more basic (and potentially less robust) method. Still, you answer is the better of the two, so marked as the answer :) –  QMKevin Oct 28 '11 at 14:02

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.