1. Open Visual Studio 2010
2. Select New Project Empty SharePoint Project
3. Provide a local site and Select "Deploy as a farm solution" option.
(Mostly, developers
don't put anything in Description but this information really comes in handy
when you are trying to figure out what a specific Feature is supposed to do in
terms of functionality)
6.
Right Click on Feature1.Feature and
Click on "Add Event Receiver"7. Uncomment the "Feature Activated" part of the code
This code is added to the following entries in web.config
- Connection Strings
- Key Value pair in AppSettings section
For each child node entry provide a
specific owner name (like "Smartrider" in my case).We will need this
as a reference later on in case you want to remove the entries (we are going to
do this during Deactivation)
string value = @"Test"
SPWebApplication webApp = SPWebApplication.Lookup(new
Uri("<URL>"));
SPWebService service = SPWebService.ContentService;
SPWebConfigModification connMod = new
SPWebConfigModification();
SPWebApplication webApp = SPWebApplication.Lookup(new
Uri("<URL>"));
SPWebService service = SPWebService.ContentService;
SPWebConfigModification connMod = new
SPWebConfigModification();
connMod.Path = "configuration";
connMod.Name = "connectionStrings";
connMod.Value = " <connectionStrings>
</connectionStrings>";
connMod.Owner = Assembly.GetExecutingAssembly().FullName;
connMod.Type
= SPWebConfigModification.SPWebConfigModificationType.EnsureSection;
webApp.WebConfigModifications.Clear();
webApp.WebConfigModifications.Add(connMod);
//SQL Connetion String
SPWebConfigModification webConfigMod = new
SPWebConfigModification();
//SQL Connetion String
SPWebConfigModification webConfigMod = new
SPWebConfigModification();
webConfigMod.Owner = "Smartrider";
webConfigMod.Type
= SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
webConfigMod.Value = String.Format("<add
name=\"{0}\" connectionString=\"{1}\"
providerName=\"{2}\"></add>", "conn", "Data
Source=<datasource>;Initial Catalog=<databasename>;Integrated
Security=True", "System.Data.SQLClient");
webConfigMod.Path
= "configuration/connectionStrings";
webConfigMod.Name = "sqlConn";
webApp.WebConfigModifications.Add(webConfigMod);
//Add NetworkShare URL
SPWebConfigModification appConfigMod = new
SPWebConfigModification();
//Add NetworkShare URL
SPWebConfigModification appConfigMod = new
SPWebConfigModification();
appConfigMod.Owner = "Smartrider"
appConfigMod.Path = "configuration/appSettings";
appConfigMod.Name = String.Format("add
[@key='NetworkURL'] [@value='{0}']", value);
appConfigMod.Value = String.Format("<add
key='NetworkURL' value='{0}' />", value);
appConfigMod.Type
= SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
webApp.WebConfigModifications.Add(appConfigMod);
webApp.Update();
service.ApplyWebConfigModifications();
- You also want to add code to remove the entry when the Feature is Deactivated. One way to do this is to find all the entries that are inserted by Owner name "Smartrider".
public
override
void FeatureDeactivating(SPFeatureReceiverProperties properties)
override
void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
SPWebApplication webApp = SPWebApplication.Lookup(new
Uri("URL"));
SPWebApplication webApp = SPWebApplication.Lookup(new
Uri("URL"));
try
{
RemoveEntries(webApp);
webApp.Update();
webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
webApp.WebConfigModifications.Clear();
}
catch (Exception ex)
{
throw ex;
}
}
//Remove Entries made to web.config by Owner name "Smartrider"
private
void RemoveEntries(SPWebApplication webApp)
//Remove Entries made to web.config by Owner name "Smartrider"
private
void RemoveEntries(SPWebApplication webApp)
{
try
try
{
List<SPWebConfigModification> entriesToRemove = new
List<SPWebConfigModification>();
List<SPWebConfigModification>();
foreach(SPWebConfigModification configMod in webApp.WebConfigModifications)
{
if(configMod.Owner == "Smartrider")
{
entriesToRemove.Add(configMod);
}
}
if(entriesToRemove.Count > 0)
{
for (int i = entriesToRemove.Count - 1; i >= 0;
i--)
{
webApp.WebConfigModifications.Remove(entriesToRemove[i]);
}
}
}
catch
{
throw;
}
}
9. Deploy the code and check the
web.config file to verify your entries.10. Done
Hemant Datta is the COO for JHC Technology. He can be reached at hdatta(at)jhctechnology.com, @hdatta, or connect with him on
LinkedIn.
Thanks for sharing the useful code,very informative for me.Please keep updating.
ReplyDeleteEpson Support Number
I really need that kind of code,your website is awesome i love it.Thanks for disclosing with us.
ReplyDeleteDell customer service
ReplyDeleteThanks for sharing this awesome piece of info. It is really very helpful.
Really i appreciate the effort you made to share the knowledge. The topic here i found was really effective to the topic which i was researching for a long time.
Lexmark Helpline Number
Hey! Nice post thanks for sharing this.....if you want any solution related to windows than visit here:
ReplyDeleteWindows Support Number
http://www.hardwareforums.com/threads/pictures-corrupted-after-cropping-with-windows-10-photo-app.53673/
Great post! Thanks you so much for the share. Keep up the Excellent work,
ReplyDeletewe look forward to reading more from you in the future!
Mobile Apps |Mobile Development
I am feeling so cheerful to examine your blog post,really dazzling post you have shared, thanks
ReplyDeleteAcer Customer Service
Hii.. it's a very wonderful blog with many ideas.. keep updating me..
ReplyDeleteLenovo Contact Number
This is my first time to visit here. I found countless interesting
ReplyDeletestuff in your weblog, especially in its discussion. I guess I’m not the only one having
all the entertainment here! Keep up the outstanding work.
Epson Printer Support
Epson Technical Support
Epson Helpline
Epson Customer Service
HP Customer Service
HP Contact Number
HP Support Number
HP Helpline Number
Canon Support
Canon Support Number
Canon Customer Service
Canon Customer Care
I am feeling so cheerful to examine your blog post,really dazzling post you have shared and I got so many information from your blog,Thanks
ReplyDeleteLenovo Contact Number
Hi I am so excited I found your blog, I really
ReplyDeletefound you by accident, while I was searching on Bing for something else, Anyhow
I am here now and would just like to say many thanks for a remarkable post and a all
round interesting blog (I also love the theme/design), I
don’t have time to read through it all at the minute but
I will be back to read a lot more, Please do keep up the awesome work
Kindle Customer Service
Lenovo Support
ReplyDeleteI really appreciate the kind of topics you post here. Thanks for sharing us a great information that is actually helpful. Good day
If you are crazy for new fashion then try this >>>
visit here
visit here
visit here
visit here
visit here
visit here
visit here
visit here
visit here
visit here
ReplyDeleteHello there, just became aware of your site via Google, and discovered that it’s truly useful. I’ll be happy if you continue this in future.
Hotmail Support Number UK
Lenovo Contact Number UK
This is my first time to visit here. I found countless interesting stuff in your weblog, especially in its discussion. I guess I’m not the only one having all the entertainment here! Keep up the outstanding work. If you are looking for Digital Marketing Services, then visit here >>>
ReplyDeleteSEO agency in delhi
SEO companies in delhi
unmanageable psychiatric patients in delhi
unmanageable psychiatric patients
ReplyDeleteThis is my first time to visit here. I found countless interesting stuff in your weblog, especially in its discussion. I guess I’m not the only one having all the entertainment here! Keep up the outstanding work. If you are looking for Digital Marketing Services, then visit here >>>
unmanageable psychiatric patients in delhi
unmanageable psychiatric patients
It's an uncommonly nice post. Genuinely refreshing to examine it till the end thanks divide such a wonderful post..
ReplyDeleteaffordable banquet in delhi
best banquet halls in rajouri garden
magnified healing
magnified healing classes
This is my first time to visit here. I found countless interesting stuff in your weblog, especially in its discussion. I guess I’m
ReplyDeletenot the only one having all the entertainment here! Keep up the outstanding work. If you are looking for Digital Marketing Services,
then visit here >>>
best website development company in delhi
best website designing company in delhi
inpatient facility for mental patients
de-addiction centre delhi
virtual classroom service providers in india
podium manufacturers in delhi
best jewellery stores in delhi
best jewellery showroom in south delhi
best interior designer in delhi
interior designer in delhi
hii dear, I got so many good information from your site.. love the stuff.. thank you so much dear..
ReplyDeleteCorrespondence PHD Programs
PHD Distance education
LLB from CRSU
mosquito net for sliding door
aluminium mosquito net door
ReplyDeleteGet free vouchers of shopping..grab the opportunity now.. go here >>>>>
Free
Shopping
Free Shopping
Free
Shopping
Free Shopping
Free Shopping
Free Shopping
Free Shopping
Very nice blog, you given useful information, Very great article, Thank you for sharing this wonderful article.
ReplyDeleteamazon cloud services in india
ReplyDeleteSuch a wonderful blog.. I found so many useful stuff from your blog.. Keep updating us like this.. If you are looking for any service regarding immigration go here >>>
Immigrate to Canada
Apply Canada Permanent Resident Visa
ReplyDeleteThis is one more mind blowing site page that has demonstrated me stunning resources which cements instructional activities and materials to the enormous class of point subject.
Canada Immigration Visa
Canada Immigration Program
Canada Permanent Resident Visa
ReplyDeleteDo Amazon Shopping and get 50% cash Back !! Offer limited !!
70% Cash Back Offer
70% Cash Back Offer
70% Cash Back Offer
70% Cash Back Offer
70% Cash Back Offer
70% Cash Back Offer
70% Cash Back Offer
70% Cash Back Offer
ReplyDeleteHello! I just wish to give an enormous thumbs up for the nice info you've got right here on this post. I will probably be coming back to your weblog for more soon
Google Digital Unlocked final Exam Answers| Free Free Free
Google Web Designers Basics Free
Check Instagram Profile Pictures in Full Size
ReplyDeleteDo Amazon Shopping and get 70% cash Back !! Offer limited !!
70% Cash Back Offer
70% Cash Back Offer
70% Cash Back Offer
70% Cash Back Offer
70% Cash Back Offer
70% Cash Back Offer
70% Cash Back Offer
70% Cash Back Offer
70% Cash Back Offer
70% Cash Back Offer
I must say a nice article has been written by the author.
ReplyDeleteCovering this topic in a single article was very difficult but I see that how nicely the author has done it.
Author has given very amazing facts and information on this interesting topic.
Immigration Consultancy Services
Top Immigration Consultants
CRS Calculator
Express Entry Points Calculator
ReplyDeleteClick here
Click here
Click here
Click here
Click here
Click here
Click here
Click here
Click here
Click here
ReplyDeleteReally, this article is to a great degree one of the most flawlessly awesome ever. I am an antique 'Article' gatherer and I now and again read some new articles if I find them entrancing. Besides, I found this one extremely enchanting and it should go into my aggregation. Great work!
digital marketing services in delhi
website designing company delhi
Thanks for this insight blog. really helpful
ReplyDeletereiki training services
ReplyDeleteI must say a nice article has been written by the author.
Covering this topic in a single article was very difficult but I see that how nicely the author has done it.
Author has given very amazing facts and information on this interesting topic.
immigration office in nehru place delhi
canada visa consultants in nehru place
Canada PR Visa Consultants
PR Visa experts
I really need this Code, thank you for sharing such important code with us..........keep updating these kind of code!
ReplyDeletePleated Mesh System
Insect Screen
Magnetic Mesh System
Velcro Mesh Systems
Double Glazed Windows
Mosquito Net For Doors and Windows
Mosquito Net for Window
Mosquito Net for Door
Mosquito Net for UPVC Sliding Window and Door
Mosquito Net
Roller Mesh System
Mosquito Window Screen
Custom Window Screens
Insect Screen Window
Insect screen shop
insect screen india
insect Screen Supplier
upvc sliding doors
upvc doors windows
upvc window manufacturers
upvc window suppliers
Mosquito Nets For Upvc Windows
upvc sliding window
mosquito mesh for window
mosquito screen window
window screen
ReplyDeleteWonderfull information given by you guys!! I hope that i'll be back again here !! Thanks
visa immigration consultants in delhi
canada visa experts in delhi
Easy Immigration
Wow... such a nice topic you are discussing here and what a info you are giving us.. thanks a lot dear.. keep updating us like this.Digital Marketing Service
ReplyDelete
ReplyDeleteGood article and have a nice content, really enjoy it. thanks for sharing.
Canada PR Visa Consultants
Immigration Consultants in India
Arotic Visa
Reiki Classes in Delhi
ReplyDeleteWhile researching for apartment friendly screen doors, i digressed and came across your blog. Thank you so much for sharing this information, it's really helpful. So i am still researching for window screens for my house. Do you guys have some kind of solution for me. I am looking for something similar to the ones in the link below.
ReplyDeletehttps://www.freedomscreens.net/freedom-infinity-zipline.php
would love to know if you have anything regarding this. Please let me know if you do. :)
Informative blog! keep your family from mosquitoes/insects Mosquito net doors and windows
ReplyDelete