Using your SharePoint site Master Page on all application pages - asp.net

I am new to share point. i would like to add custom .aspx pages in share point. this i was able to do it using this blog http://chiragrdarji.wordpress.com/2007/10/12/add-aspx-page-to-sharepoint-2007/#comment-3540 .. now i would to inherit the share point's master page in my asp.net application and implement some controls. can any one help me out regarding this?
thanks and regards
malathy.L.

Using the sharepoint master page in another app is not going to work. It has a bunch of sharepoint specific controls on it that your custom app won't recognize. It is much easier to put all your app's logic (i.e. all controls now in an ASPX page) in a USerControl and use those on ASPX pages in SharePoint.
Then to be able to use these controls you need to do either of these options:
Then deploy either by putting the .ascx files in the CONTROLTEMPLATES folder in SHarePoint's 12 hive and the DLL in the bin folder / Global Assembly cache. If you go for the BIN folder you would probably need to write CAS Policy files though. This is the most secure method.
use the SmartPart.
I'm guessing you are very new to SharePoint , but want to urge you to consider packaging all this up in a SharePoint Solution (a .wsp file) using a tool like WSPBuilder.
Also I would encourage you to read up on SharePoint Development / Deployment Best Practices check out this Checklist.

Related

I can't find options for Select Master Page or Place code in separate file in VS2012

I installed VS 2012 on my work PC, and for the life of me when I go to add a new web form, I cannot see or find the 2 options for Select Master Page or Place code in separate file.
Any ideas on how i can find them?
I've just been fooled by just that for the past hour. What I've found is that the 'old' method of using the menu option 'Add web page using master' (or similar) has vanished, and been replaced by 'Content Page'. When you select this, you're then given the option of choosing a master page.
Incidentally, I don't get the option of starting a web site project, which may be why I'm not seeing this either.
You should have web form with master page in the add items?
Placing code in separate file is a different concept called code-behind. You will have an ASPX file and a cs / vb file which handles the events.
e.g.
Default.aspx
Default.aspx.cs
EDIT: Based on comment.
You may be using a Web Site on your laptop, but a Web Application in work. See Web Application Projects v's Web Site Projects.
Take a look at ASP.NET Web Site or ASP.NET Web Application?, this might also help in deciding which to use. Generally, I always go for Web Application.
You can use VS to convert from a Web Site to a Web Application, but AFAIK, you can't do it the other way round unless you create a new project and copy across the relevant parts - which could be a big job depending on the size of the site.

How do I deploy an Asp.net web application to a Sharepoint 2010 site using WSP

Suppose I created a custom web application that consists of:
several assembly DLLs: web app, business logic, data services
multiple aspx pages and ascx custom controls that use them
custom configuration section
custom HTTP module
More or less the usual stuff.
I would like to deploy it to a particular sharepoint site under a certain subfolder. So if I access my sharepoint site via http://myserver:90/ (because I'm not using sites/some_site) I'd like my application to be available under http://myserver:90/webapp
I could manually add a virtual folder (not application because I would need to access some Sharepoint site's data) to my sharepoint site in IIS and manually edit site's web.config file to register my HTTP module and add my custom configuration section as well either putting my DLLs into GAC or put them in the _app_bin (so I don't have problems with CAS), but I don't think that's a good thing to do, because this web application may get deployed in an environment where this shouldn't/couldn't be possible.
So I figured I could build a WSP using Visual Studio 2010 and deploy it that way. But I don't have enough experience doing that.
I created a new sharepoint 2010 project. Is there a way I could add all non-executable application files (aspx, ascx) at once? I've seen the advanced tab of the WSP package where I can add my DLLs either to bin folder or GAC. I don't know whether I would also have to add any safe control and register certain classes?
So I suppose I need some pretty detailed and explanatory guidance here.
The only real way to do this would be to use the layouts folder to deploy your application via the wsp. This will let you depot any files that you would normally deploy with a.web application.
There are couple of problems however. The URL for your application will be http://SharePoint/somesite/_layouts/yourapp
This is a blessing and a curse. Your urls will be ugly but they will work under every SharePoint site. If your application depends on SharePoint context to function, that context will automatically be available based on the requesting URL.
To add a layouts folder under your share point project right click on the project and add a mapped folder to layouts. I would also recommend adding a sub folder under layouts for your application so that your application files don't conflict with the default files directly in the layouts folder.
For the http module, or any web.config modifications, you can use the spwebconfigmodification class.
Heres a walkthru: http://sharepointsolutions.blogspot.com/2006/12/using-spwebconfigmodificat_116736917110571614.html

Add asp.net pages into sharepoint

How to add or open the asp.net pages from inside sharepoint?
I found many info on the web about that, but they all fail or they are not clear. I appreciate your help :)
Your question is not clear, but if you want to customize look'n'feel of SharePoint page you should use SharePoint Designer.
In case you want to create some additional functionality from scratch the easiest way is to create a custom web part and then add it to a SharePoint page.
I think you want to include an aspx page to call either using an AJAX include or to be able to use the MOSS Object Model without having to add references etc?
if so then the following steps are necessary:
navigate to 12\layouts\
create a folder for the asp.net files
put the inline code files in
From sharepoint you can add a page viewer web part and reference it with the following url _Layouts//Filename.aspx
This technique will only work with inline code, if you wish to compile your code then you would create the site as normal and then add an application folder within the virtual directory of that particular site for example my site is called intranet:
navigate to c:\inetpub\wwwroot\wss\intranet
add your asp.net folder to this as a sub folder
in inetmgr right click the folder and create an application for it (use the same app pool as the sharepoint site)
ensure ALL DLLs from the sharepoint site bin folder exist within the apps bin folder or it will throw an error.
However, I would only ever use these methods as proof of concept and would ultimately use web parts, custom features and workflows to carry out the same functions.

Creating Xaml control in (aspx)web application

Is it possible to create a .xaml (silverlight) control in a web application project?
I have an aspx application wherein I am using ajax controls and updatepanel. I want to create some silverlight controls in the same project, and load it along with my other pages/controls.
I am not sure if it is possible to create a silverlight control without having a dedicated silverlight project template.
I think your question is the same as one of mine: Is there a way to insert Silverlight XAML into my page using ASP.NET code-behind?
If so, the answer is basically "not in any sane way, but you can hack it by setting up different parameters (as in weiqure's answer) and using them to dynamically generate the XAML."
I'm not sure if this answers your question, but you can have a solution file that contains your web app and a Silverlight control. Then, to include the control in your web app, add it via the "Silverlight Applications" tab in the web app's project configuration. This will auto-update the .xap file in the web app's ClientBin folder.
Alternatively, you can create the Silverlight control in its own project/solution outside of the web app solution. Then you just need to copy in the .xap file to the web app's ClientBin and add it to your aspx page the usual way. I've found this approach useful when I want to deploy the same control to multiple web sites/projects.
Instead of creating several controls you might try creating one control that dynamically creates it's own content.
You can tell the control what to do by passing initialization parameters to it. Here's the MSDN tutorial and here's a blog post about it.
I think this approach is no worse than creating controls dynamically. You can probably send it XAML markup (I'm not sure if I remember that correctly, though), otherwise you could path something like "myButton=Type:System.Windows.Controls.Button;Content=Click me!" and then use reflection.

How to store an ASP.NET master page in a common library?

We would like to have several internal web applications which use the same master page. Is there a way to store a master page in a common library referenced by all projects?
You can do this, but it is difficult and has quite a few drawbacks.
This process is similar to packaging up user controls as well. Basically you have a web application project that contains your master page. You can precompile this into a set of dlls using aspnet_compiler.
then you can use ilmerge.exe to put them all into a single dll that you then reference from your other projects.
You still need to have the markup in order for your pages to render properly in the designer, so you'll probably have to investigate VirtualPathProviders as well.
It's a kludgy solution and it has many drawbacks.
I've heard this works, I haven't tested it.
Create a separate project to house your master pages, since all master pages are like user controls and built into their own separate assembly. Run the build and try referencing the assembly of the master page.
Again, not tested, just something I've read before.
G'luck with it!
Given that these modules are part of the same web application, you should look at this approach:
Basically, you have one root web, which is set up as the(only) IIS web application.
You may plug in new web modules by creating ASP.NET Web Application projects and place under the root web, physically.
Set the build directory to root web's bin, eg. "..\bin". Don't create a IIS application/virtual directory.
Thereby, each web module compiles into its own DLL, which is itself a good thing.
When compiling, it is "merged" with the root web.
It is a great way for sharing master pages and user controls, and have different parts of the web site in different projects/assemblies.
Master pages and user controls will even work in design mode.
Hope this helps
Sharing master page across the application
Enjoy.. :)

Resources