Code source works fine from console application but not from SharePoint interface
Hi;
Please can you help
me to understand why my code below works fine from console application (VS 2010) and not working from interface of my SharePoint collection site :
From console application : the subsite is created and I can to open without any problem
From Sharepoint GUI : the subsite is created but impossible
to open subsite : error 404 page not found ?
The subsite creation is very long (2 minutes) and in concole application When I try to open the subsite just after its creation I have page not found and I must waits (several refresh) more time to open the subsite correctly.
Can be I must to display a PoPup to show the progress creation ?
using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;
namespace CreateSubSiteClients.EventReceiver1
public class EventReceiver1 : SPItemEventReceiver
public override void ItemAdded(SPItemEventProperties properties)
base.ItemAdded(properties);
try
SPWeb web = properties.OpenWeb();
if (properties.List.Title == "REFCLIENTS")
SPListItem curItem = properties.ListItem;
string name = properties.ListItem["SITE"].ToString();
curItem["SiteUrl"] = web.Url + "/" + name;
SPWeb rootWeb = web.Site.RootWeb;
SPWebTemplateCollection webTemplates = rootWeb.GetAvailableWebTemplates(1036);
SPWebTemplate webTemplate = null;
String webTemplateName = "ModeleSiteCourrier";
String webTemplateSearchName = "";
for (int i = 0; i < webTemplates.Count; i++)
webTemplateSearchName = webTemplates[i].Name.ToString();
if (webTemplateSearchName.Contains(webTemplateName))
webTemplate = webTemplates[webTemplateSearchName];
break;
SPWeb newSite = web.Webs.Add(name, name, name, Convert.ToUInt16(1036), webTemplate, false, false);
newSite.Navigation.UseShared = true;
newSite.Update();
newSite.Close();
Console.WriteLine("Le site suivant a été crée", name);
catch (Exception ex)
properties.Status = SPEventReceiverStatus.CancelWithError;
properties.ErrorMessage = ex.Message.ToString();
properties.Cancel = true;
Regards
Hi,
To create subsite using event receiver in SharePoint Empty Project, you can refer to:
Sharepoint 2010 event handler to create subsites
To display a PoPup to show the progress creation, you can use: MessageBox.Show("Hello, world.");
More information:
MessageBox.Show Method (String)
Best Regards,
Linda Li
Linda Li
TechNet Community Support
Similar Messages
-
How do I connect to Net Flix? I put in my user name and password which work fine with my iMac but not on my Apple TV?
Can you give me a screenshot of the User Accounts window in Control Panel?
Please create a screenshot by following the guide mentioned at [[How do I create a screenshot of my problem?]].
Once you've done this, attach the saved screenshot file to your forum post by clicking the '''Browse...''' button below the ''Post your reply'' box. You really help us to visualize the problem. -
Question
WHEN I GO TO PRIVACY SETTINGS AND CLICK ON EXCEPTIONS AND TYPE IN A WEB ADDRESS TO ALLOW ALL THE TIME IT DOES NOT SAVE IT THE NEXT TIME I SIGN ON TO FIRE FOX IT IS LOST. IT WORKS FINE ON MY DESKTOP BUT NOT ON MY LAPTOP THAT I JUST BOUGHT in English.I just updated my whatsapp...clicked on whatsapp in appstore and now can access my whatsapp
-
BDC with call transaction VD02 works fin in A mode but not in N mode
Hi All,
I have BDC program developed in 4.6c using call transaction VD02 works fine with mode A but not with mode N.
Now we upgraded to ECC 6.0.Do I need to change anything?No, you don't have to change anything for ECC. BTW, I wonder why VD02 is not working in the background for you?
-
HP officejet Pro 8100 will print from an Iphone but not from my windows laptop
HP officejet Pro 8100 will print from an Iphone but not from my windows laptop. I get an error stating "unable to communicate with printer"
Hi Melatina66,
Welcome to the HP Support forums. I understand that when trying to print from your laptop that you get a communication error message.
To better assist you, would you please provide some further information:
1) How is the printer connected (USB cable, ethernet or wireless)?
2) When you installed the printer on your laptop did you set it up with a USB cable? If yes, did you switch the connection type on the laptop from USB cable to ethernet/wireless?
3) What version of Windows operating system are you running on the laptop (Windows XP, Windows Vista, Windows 7, or Windows 8, etc)?
4) When printing from your iPhone are you using Apple's AirPrint or HP's ePrint app?
Thank you.
Regards,
Happytohelp01
Please click on the Thumbs Up on the right to say “Thanks” for helping!
Please click “Accept as Solution ” on the post that solves your issue to help others find the solution.
I work on behalf of HP -
my music has disappeared from my computer but not from my ipad...how do i transfer it back
Use a third party PC/Mac music transfer application like Senuti.
-
How do I download a home DVD video disk (-R) to iMovie where I can then edit? I can download from a camera, but not from the disk.
iPhoto pulls off new videos from my iPhone 5 just fine. Does iPhoto automatically come up when you connect your iPhone? If it does, you should see your iPhone under "Devices" in iPhoto and then can select the videos to transfer (select, then Import Selected), though that should happen automatically.
-
Delete emails from iPhone 5 but not from server?
How do I delete emails from iPhone 5 but not from server?
If its a POP account try this:
Go to Settings>Mail, Contacts and Calendars
Tap on your mail account
Scroll to the bottom
Tap on Advanced
Tap on "Delete from server" and set it to "Never" -
couldn't find the adequate forum. I run win 8.1 and the adobe acrobat dc app on my computer doesn't access the doc cloud. I can´t turn the mobile link on. I can access the cloud from my browser, but not from the desktop app. I can access from my mobile app.
Can you please post a screenshot of your Acrobat DC when launched, without opening a PDF?
Thanks,
-Amboo -
how can I delete some music from my iCloud but not from my iTunes in my computer? please??
iCloud doesn't store your music.
-
I do not like to accumulate 3rd party cookies and would simply not check the Accept 3rd Party Cookies box in Preferences. BUT in order to use my bank's web page I have to accept 3rd party cookies from a separate site that manages some of their transactions (like paying bills). This means I have to accept 3rd party cookies and then delete them by hand OR I have to check the accept box each time I use the bank's website and then uncheck it when I am done.
Thanks, but that is not what I was trying to do. I do not want to block cookies from a single site. I do not want to block all 3rd party cookies.
What I want to do is ACCEPT 3rd party cookies only from ONE site but NOT from any other site. -
I have an iPad mini and an iPad 2. I can print email to my HP 6510 from the mini, but NOT from the iPad 2. Both are on the same wi-fi network. I have tried everything I can do including unplugging everything, restarting, etc. Can anyone help?
Thanks so much! My grandaughters played games on the iPad over Xmas and one of their moms said shed restricted their access! Guess they forgot to enable again. Thank you again! Karla
-
Using QuickTime Pro with an .mpg movie, why can I only get it to play from the beginning, but not from any other point in the video? How can I fix this?
Baffled in SBWhat format of MPG is this? Is this an MPEG1 or MPEG2 video? How was the video created?
-
I can print from my iPhone but not from my iPad
I Can print from my iPhone, but not from my iPad. The options
select a printer and number of copies are active. The print
button is not active ( hot ).Try this - Reset the iPad by holding down on the Sleep and Home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons. (This is equivalent to rebooting your computer.) No data/files will be erased. http://support.apple.com/kb/ht1430
AirPrint Setup and Troubleshooting
http://www.apple.com/support/ipad/assistant/airprint/
How to print from your new iPad using AirPrint
http://www.imore.com/print-ipad-airprint
AirPrint Basics
http://support.apple.com/kb/ht4356
Cheers, Tom -
I can print from my Mac but not from my iPad.
I can print from my Mac but not from my iPad ,any ideas?
you can read here about airprint
http://support.apple.com/kb/HT4356
if the printer don't support that then you need to find a printing app in app store
which will act the role as printer driver for the device to speak with the printer
Maybe you are looking for
-
I closed a Firefox process. Then clicked the FF icon to restart my browser. I received an error message. " Firefox is already running, but not responding. To open a new window you must first close existing Firefox process, or restart your system. How
-
I have my daughters Ipod, my iphone, my wife's Iphone and Ipad on the one Apple ID. Since the latest update we are receiving Imessages from our daughter's Ipod with my wife's caller ID on the one message strand. Is it possible to differentiate betw
-
Extract file...I want the logic for the following case.
Hi Guys, i_final having the following inputs. I_FINAL MATNR MAKTX CHARG SK45
-
Graphics-smartforms(urgent !)
Hi, I'm developing a letter in smartforms. I need to print graphic (signature of HR) inline with the text. For this I've included the statement: BITMAP 'SIGN' OBJECT GRAPHICS ID BMAP TYPE BCOL DPI 100 in the textmodule, but it's not getting printed.
-
Is it possible to return an operator-type from a function/decode ?
Hi , I have a query that is calling a decode and based on the operator type (i.e <> , >= , <= etc ..) that it returns to compare 2 fields of a table is this possible and if so could anyone advise me how to ? below is my current declaration that gives