<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Redirecting from NewForm.aspx to DispForm.aspx after creating a new item</title>
	<atom:link href="http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/</link>
	<description>Verschiedene Gedanken rund um die Softwareentwicklung</description>
	<lastBuildDate>Thu, 20 Oct 2011 12:35:44 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Michael</title>
		<link>http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/comment-page-1/#comment-880</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Mon, 21 Jun 2010 16:10:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/#comment-880</guid>
		<description>Hi everyone.

I feel obliged to post my solution on this site since I&#039;ve had a very similar problem to all of you and this site helped me out.

I had to redirect a user after they uploaded and captured the metadata of a document. I also therefore struggled with the lack of context vs not having the metadata saved.

After the file has been uploaded, SharePoint assigns a SPListItem to it and then you are typically redirected to a CRUD screen where you capture this metadata. This got me thinking that I should try to get hold of &#039;THAT&#039; item and add to it&#039;s metadata instead of trying to add a new list item. This will therefore be un intercept of the update, never the add.


Here is the snippet (sorry for the mess but this window is a little small to copy code)

public override void ItemUpdating(SPItemEventProperties properties)
        {
            SPSite siteColl = null;
            SPWeb site = null;
            string url = null;
            bool hasError = true;
            try
            {

                siteColl = new SPSite(properties.SiteId);
                site = siteColl.OpenWeb(properties.RelativeWebUrl);
                SPList list = site.Lists[properties.ListId];
                
                SPFile file = properties.ListItem.File;
                
                // Add the item and fill it with the values from properties
                DisableEventFiring();
                
                //Note that the &#039;reserved&#039; columns in SharePoint uses the &#039;vti_&#039; prefix for it&#039;s property attributes

                    file.Item[BusinessObjects.Entities.KnowledgeBaseArticle.ARTICLE_TITLE] = properties.AfterProperties[&quot;vti_title&quot;];
                    file.Item[BusinessObjects.Entities.KnowledgeBaseArticle.CATEGORY] = properties.AfterProperties[&quot;Category&quot;];
                    file.Item[BusinessObjects.Entities.KnowledgeBaseArticle.RELATED_TO] = properties.AfterProperties[&quot;RelatedTo&quot;];
                    file.Item[BusinessObjects.Entities.KnowledgeBaseArticle.DESCRIPTION] = properties.AfterProperties[&quot;vti_description&quot;];
                    file.Item[BusinessObjects.Entities.KnowledgeBaseArticle.RATING_VALUE] = properties.AfterProperties[&quot;RatingValue&quot;];
                    file.Item.Update();
                    file.CheckIn(null);
                    hasError = false;
                  
                //build url
                url = GetRelativeURL(properties.ListTitle, file.Item.ID);
            }
            catch (Exception ex)
            {
                Helper.EventLogHelper.LogException(ex);
                hasError = true;
            }
            finally
            {
                EnableEventFiring();
                // Cleanup
                site.Dispose();
                siteColl.Dispose();               
            }
            if (hasError == false)
            {
                // Redirect
                SPUtility.Redirect(url, SPRedirectFlags.RelativeToLayoutsPage, _currentContext);
            }
        }


I hope that this code can help someone as the result for me was that that file was uploaded successfully and that the metadata that I needed was indeed captured. 

Kind regards
Michael</description>
		<content:encoded><![CDATA[<p>Hi everyone.</p>
<p>I feel obliged to post my solution on this site since I&#8217;ve had a very similar problem to all of you and this site helped me out.</p>
<p>I had to redirect a user after they uploaded and captured the metadata of a document. I also therefore struggled with the lack of context vs not having the metadata saved.</p>
<p>After the file has been uploaded, SharePoint assigns a SPListItem to it and then you are typically redirected to a CRUD screen where you capture this metadata. This got me thinking that I should try to get hold of &#8216;THAT&#8217; item and add to it&#8217;s metadata instead of trying to add a new list item. This will therefore be un intercept of the update, never the add.</p>
<p>Here is the snippet (sorry for the mess but this window is a little small to copy code)</p>
<p>public override void ItemUpdating(SPItemEventProperties properties)<br />
        {<br />
            SPSite siteColl = null;<br />
            SPWeb site = null;<br />
            string url = null;<br />
            bool hasError = true;<br />
            try<br />
            {</p>
<p>                siteColl = new SPSite(properties.SiteId);<br />
                site = siteColl.OpenWeb(properties.RelativeWebUrl);<br />
                SPList list = site.Lists[properties.ListId];</p>
<p>                SPFile file = properties.ListItem.File;</p>
<p>                // Add the item and fill it with the values from properties<br />
                DisableEventFiring();</p>
<p>                //Note that the &#8216;reserved&#8217; columns in SharePoint uses the &#8216;vti_&#8217; prefix for it&#8217;s property attributes</p>
<p>                    file.Item[BusinessObjects.Entities.KnowledgeBaseArticle.ARTICLE_TITLE] = properties.AfterProperties["vti_title"];<br />
                    file.Item[BusinessObjects.Entities.KnowledgeBaseArticle.CATEGORY] = properties.AfterProperties["Category"];<br />
                    file.Item[BusinessObjects.Entities.KnowledgeBaseArticle.RELATED_TO] = properties.AfterProperties["RelatedTo"];<br />
                    file.Item[BusinessObjects.Entities.KnowledgeBaseArticle.DESCRIPTION] = properties.AfterProperties["vti_description"];<br />
                    file.Item[BusinessObjects.Entities.KnowledgeBaseArticle.RATING_VALUE] = properties.AfterProperties["RatingValue"];<br />
                    file.Item.Update();<br />
                    file.CheckIn(null);<br />
                    hasError = false;</p>
<p>                //build url<br />
                url = GetRelativeURL(properties.ListTitle, file.Item.ID);<br />
            }<br />
            catch (Exception ex)<br />
            {<br />
                Helper.EventLogHelper.LogException(ex);<br />
                hasError = true;<br />
            }<br />
            finally<br />
            {<br />
                EnableEventFiring();<br />
                // Cleanup<br />
                site.Dispose();<br />
                siteColl.Dispose();<br />
            }<br />
            if (hasError == false)<br />
            {<br />
                // Redirect<br />
                SPUtility.Redirect(url, SPRedirectFlags.RelativeToLayoutsPage, _currentContext);<br />
            }<br />
        }</p>
<p>I hope that this code can help someone as the result for me was that that file was uploaded successfully and that the metadata that I needed was indeed captured. </p>
<p>Kind regards<br />
Michael</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Praveen</title>
		<link>http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/comment-page-1/#comment-785</link>
		<dc:creator>Praveen</dc:creator>
		<pubDate>Mon, 05 Apr 2010 19:22:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/#comment-785</guid>
		<description>Here is the solution and nice explanation for the issue, No item exists at url and moved or renamed by another user is here.
http://praveenbattula.blogspot.com/2010/02/sharepoint-exception-no-item-exists-url.html</description>
		<content:encoded><![CDATA[<p>Here is the solution and nice explanation for the issue, No item exists at url and moved or renamed by another user is here.<br />
<a href="http://praveenbattula.blogspot.com/2010/02/sharepoint-exception-no-item-exists-url.html" rel="nofollow">http://praveenbattula.blogspot.com/2010/02/sharepoint-exception-no-item-exists-url.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marc D Anderson</title>
		<link>http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/comment-page-1/#comment-524</link>
		<dc:creator>Marc D Anderson</dc:creator>
		<pubDate>Mon, 09 Nov 2009 20:54:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/#comment-524</guid>
		<description>In my jQuery Library for SharePoint Web Services ( http://spservices.codeplex.com ), I’ve implemented this in an assembly-free way using jQuery and SharePoint’s Web Services. Simply drop a simple function call into the page, and the redirection happens, like magic!

M.

Sorry - poor typing in my previous comment for the links.</description>
		<content:encoded><![CDATA[<p>In my jQuery Library for SharePoint Web Services ( <a href="http://spservices.codeplex.com" rel="nofollow">http://spservices.codeplex.com</a> ), I’ve implemented this in an assembly-free way using jQuery and SharePoint’s Web Services. Simply drop a simple function call into the page, and the redirection happens, like magic!</p>
<p>M.</p>
<p>Sorry &#8211; poor typing in my previous comment for the links.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Bartels</title>
		<link>http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/comment-page-1/#comment-406</link>
		<dc:creator>Eric Bartels</dc:creator>
		<pubDate>Mon, 25 May 2009 07:15:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/#comment-406</guid>
		<description>Hi Christiane,

the @ID parameter seems to be misplaced?! Why is the xsl-parameter inside a GUID?
The Url of an item should be something like this http://example.org/Lists/DispForm.aspx?ID=5.</description>
		<content:encoded><![CDATA[<p>Hi Christiane,</p>
<p>the @ID parameter seems to be misplaced?! Why is the xsl-parameter inside a GUID?<br />
The Url of an item should be something like this <a href="http://example.org/Lists/DispForm.aspx?ID=5" rel="nofollow">http://example.org/Lists/DispForm.aspx?ID=5</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christiane</title>
		<link>http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/comment-page-1/#comment-399</link>
		<dc:creator>Christiane</dc:creator>
		<pubDate>Wed, 13 May 2009 12:05:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/#comment-399</guid>
		<description>javascript: {ddwrt:GenFireServerEvent(&#039;__commit;__refresh;__redirect={../../Workflows/WorkflowA/Workflow 1.aspx?List_x003D_e62e146c-f505-4a05-851b-d45bf9713c1d&amp;ID_x003D__x007B_@ID_x007D_&amp;TemplateID_x003D__x007B_62e83e8c-883a-4f89-9f7b-65b32976557a_x007D_&amp;Source_x003D_https%3A%2F%2Ferlh10wa%2Eww005%2Esiemens%2Enet%2Fsites%2Feshs%2Fpublic%2Fschulung%2Fchristiane%2Fdefault%2Easpx}&#039;)}</description>
		<content:encoded><![CDATA[<p>javascript: {ddwrt:GenFireServerEvent(&#8216;__commit;__refresh;__redirect={../../Workflows/WorkflowA/Workflow 1.aspx?List_x003D_e62e146c-f505-4a05-851b-d45bf9713c1d&amp;ID_x003D__x007B_@ID_x007D_&amp;TemplateID_x003D__x007B_62e83e8c-883a-4f89-9f7b-65b32976557a_x007D_&amp;Source_x003D_https%3A%2F%2Ferlh10wa%2Eww005%2Esiemens%2Enet%2Fsites%2Feshs%2Fpublic%2Fschulung%2Fchristiane%2Fdefault%2Easpx}&#8217;)}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christiane</title>
		<link>http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/comment-page-1/#comment-398</link>
		<dc:creator>Christiane</dc:creator>
		<pubDate>Wed, 13 May 2009 12:03:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/#comment-398</guid>
		<description>Hi Eric,

thank you for the quick response. The button I added has this code:



I thought that when I add the &quot;commit&quot;-Action before the &quot;Redirect&quot;-Action, the ID is already set?</description>
		<content:encoded><![CDATA[<p>Hi Eric,</p>
<p>thank you for the quick response. The button I added has this code:</p>
<p>I thought that when I add the &#8220;commit&#8221;-Action before the &#8220;Redirect&#8221;-Action, the ID is already set?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Bartels</title>
		<link>http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/comment-page-1/#comment-397</link>
		<dc:creator>Eric Bartels</dc:creator>
		<pubDate>Wed, 13 May 2009 11:56:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/#comment-397</guid>
		<description>Hi Christiane,

can you provide your xslt-code from your DataFormWebPart?

What is a problem is the fact that when you are &quot;inside&quot; NewForm.aspx the new id of the item is not set. After submitting the form the item gets created and an id is assigned.</description>
		<content:encoded><![CDATA[<p>Hi Christiane,</p>
<p>can you provide your xslt-code from your DataFormWebPart?</p>
<p>What is a problem is the fact that when you are &#8220;inside&#8221; NewForm.aspx the new id of the item is not set. After submitting the form the item gets created and an id is assigned.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christiane</title>
		<link>http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/comment-page-1/#comment-396</link>
		<dc:creator>Christiane</dc:creator>
		<pubDate>Wed, 13 May 2009 11:32:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/#comment-396</guid>
		<description>Hi iyad,

tried the same like you in SPD, however, when I add the parameter ?ID={@ID} to the link, sharepoint does not take the correct ID of the current item, but {@ID} appears in the link. Does anyone know how to overcome this?</description>
		<content:encoded><![CDATA[<p>Hi iyad,</p>
<p>tried the same like you in SPD, however, when I add the parameter ?ID={@ID} to the link, sharepoint does not take the correct ID of the current item, but {@ID} appears in the link. Does anyone know how to overcome this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/comment-page-1/#comment-367</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Wed, 18 Mar 2009 11:15:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/#comment-367</guid>
		<description>&lt;strong&gt;@iyad&lt;/strong&gt;
Yes, I&#039;m know this is possible but I really dislike &quot;solutions&quot; where the SharePoint Designer is involved :-)</description>
		<content:encoded><![CDATA[<p><strong>@iyad</strong><br />
Yes, I&#8217;m know this is possible but I really dislike &#8220;solutions&#8221; where the SharePoint Designer is involved <img src='http://www.entwicklungsgedanken.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: iyad</title>
		<link>http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/comment-page-1/#comment-365</link>
		<dc:creator>iyad</dc:creator>
		<pubDate>Mon, 09 Mar 2009 22:56:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/#comment-365</guid>
		<description>actually great job ,but there is a very easy way to accomplish the same approach using Share Point  designer ,just edit the newform.aspx page and replace the behavior of the OK and Cancel button ,the default behavior is to commit and redirect to Allitems.aspx ,just replace it with commit and redirect to Dispform.aspx with any query  string parameter you want .
i&#039;v try your code but HttpContext.Current always null even inside the constructor?? any idea ?????</description>
		<content:encoded><![CDATA[<p>actually great job ,but there is a very easy way to accomplish the same approach using Share Point  designer ,just edit the newform.aspx page and replace the behavior of the OK and Cancel button ,the default behavior is to commit and redirect to Allitems.aspx ,just replace it with commit and redirect to Dispform.aspx with any query  string parameter you want .<br />
i&#8217;v try your code but HttpContext.Current always null even inside the constructor?? any idea ?????</p>
]]></content:encoded>
	</item>
</channel>
</rss>

