SharePoint – Connection String dialog box during FeatureActivated event

Question :

SharePoint – Connection String dialog box during FeatureActivated event,

Answer :

Does anyone know if it is possible to display a prompt to a user/administrator when activating or installing a sharepoint feature?

I am writing a custom webpart and it is connecting to a separate database, I would like to allow the administrator to select or type in a connection string when installing the .wsp file or activating the feature.

I am looking inside the FeatureActivated event and thinking of using the SPWebConfigModification class to actually write the connection string to the web.config files in the farm.

I do not want to hand edit the web.configs or hard code the string into the DLL.

Read More  Cannot add WebViewer of ActiveReports to an ASP.NET page

If you have other methods for handling connection strings inside sharepoint I would be interested in them as well.

,

Unfortunately there is no way to swap to a screen where you can get user via the feature activation process. Couple of comments for you:

  1. I’m assuming the connection string is going to be different for every installation, so there is no way you can include it directly in the Solution.
  2. I’m assuming that you couldn’t programmatically construct this during installation.

Therefore, you need some way to get user input. Here are a couple of options:

  1. It could be a web part property, though this would mean setting it each and every time the web part was added, and you would need to then maitain those settings individually.
  2. You could build out your own _layouts settings screen (good post:, and from there users can maintain the property, storing it in either the Web Property bag, or inside the Web.Config. I try to avoid using the Web.Config where I can, but if you do wish to go this route then MAKE SURE you use the SPWebConfigModification class (Read this great blog:
  3. Finally, a technique I often use is storing configuration information in a SharePoint List. Chris O’Brien has a great framework for that here:
Read More  Advancing through relative dates using strtotime()

Hope that helps,
Daniel

That’s the answer SharePoint – Connection String dialog box during FeatureActivated event, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you

Read More  What good technology podcasts are out there?