Question

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.

Était-ce utile?

La solution

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top