Run a aspx page into a Sharepoint folder - c#

I have a aspx page and I'd like to run it into a sharepoint folder. Is there a way to execute this page like a html page? What I really need is to run a c# code that is together the aspx page (code behind) to read a SQLite database and shows the result in a good interface (html-css-javascript).
Obs.: I have a assembly reference for the SQLite.
Thanks a lot!

You need to create an application page inside sharepoint and move your code in that application page. its very simple, please see this link.
http://www.c-sharpcorner.com/uploadfile/anavijai/how-to-create-custom-sharepoint-2010-application-page-using-visual-studio-2010/
Please note that application page only support web forms and not MVC

Not sure "run it into a sharepoint folder" means... You can't have page with code behind in regular SharePoint folders.
You can put ASPX pages (even with codebehind) in Layouts folder on server's disk and they will be avaiable with ....\layouts\your_page.aspx urls.

Related

using html source instead of actual aspx page

Somehow i have lost my source code but i have published project in precompile state on my hosted server. i am able to recover c# code using decompilers but unable to find the aspx pages code as they are in compiled form. when i view them in decompiler they just show me the C# code of aspx page which is not helping me.
Initially i decided to reconstruct them on the basis of GUI but its taking too much time. My questions is , is this possible i can use the html source of page instead of its actual aspx code ? i have the c# code for my page but no aspx code so if its possible just to copy the html in aspx file and try to run if this works?

ASPX website HTML Edit

Good morning,
I have a website that I have to edit for a client, but the website is on a local web server that is designed in aspx. I am looking at all the files and when trying to change Form options I am unable to find the HTML code behind the runat=server
what i ultimately need to accomplish is to change the options in a dropdown menu that allows users to choose from.
I am sorry if i am unable to explain it in depth, my web programming is weak when dealing with this.
Once published, an asp.net site would compile the code behind into a dll, you cannot see the code, only the markup.
Solution is to edit your website in visual studio and republish.

Add a new aspx page to a published website

I have a .Net website which is published. Now I need to add a new page to the website but I do not have the source code which means that I cannot recompile and republish the website. I know that I can add an HTML page for this as the content for the new page is just plain HTML but that would show .html extension in the browser which I don't want. Is there any way to add an aspx page or html page is the only option I have ?
Yes you can add pages without recompiling, just ensure the pages don't reference a code-behind file. You'll still be able to use code in the actual page itself, as well as reference controls (.ascx files).
alternatively, you can add a create an application and then add it as an application under the original website. As in, in IIS, right click on the original site, then Add Application; and put your new application into it. Your new application will have it's own application pools and is an application by its own right without needing the original site's data.

Add general C# code to a SharePoint 2010 site page

I want to add a C# class to an existing SharePoint 2010 site page. The site page, being created either through the SharePoint UI or in SharePoint Designer, has a web part on it that I want to access and edit its properties. I could just make an invisible web part in Visual Studio, deploy it on the page, and run the code I want to run that way, but I feel like that may be bad practice (or is it)?
I'm kind of talking about how a general non-SharePoint .aspx page can reference a C# file, kind of like below:
<%# Page language="C#" Inherits="System.Web.UI.Page" CodeFile="Example.cs" %>
Would a line like above be added to the .aspx file? How is the .cs file actually deployed on the SharePoint site? Finally, is this even possible?
I'm new to SharePoint and to this site, so I appreciate all help!
By default, SharePoint does not support code behind files in regular pages for security reasons (although, as alfonso mentioned, inline code and code behind files are supported by application pages). You can override this setting in the web.config, but that is not considered to be a good practice.
You certainly could create another web part to do what you want. I have done something similar to that before. But typically, when I want to change the behavior of a custom page, I change the Inherits attribute of the Page directive:
<%# Page
language="C#"
DynamicMasterPageFile="~masterurl/default.master"
Inherits="MyNamespace.MyClass, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
%>
Create your class, have it inherit from System.Web.UI.Page, then deploy it to the GAC. Not only is this supported, but this is how most of the out of the box SharePoint pages do it.
I think there's no "correct" way to do this with a site page. The only way would be using webparts as you said, or user controls. However, you can add code very easily to an application page. This guy explains this very well.
You should have a look at the developer modules for SharePoint on MSDN
http://www.mssharepointdeveloper.com
There are various ways how to customize SharePoint 2010 as already mentioned earlier here you could use
WebParts
ApplicationPages or LayoutsPages
Custom MasterPages
DelegateControls
There are more ways how to extend SharePoint, so it really depends on your situation or on the requirement you've to achieve.

Using Admin Panel How we can create a aspx page in sitefinity?

how we can create the dynamic page ex. help.aspx and write the code in sitefinity. Because i facing a problem I create a page but i unable to know in which directory the page is lived. If any one help me Suggest.
http://abc.com/sitefinity/admin/pages.aspx
I'm not exactly sure I understand your question correctly. When you create a page in Sitefinity, it doesn't create an ASPX file. The data for the page is kept in the database and served from there. There are no physical files involved.
If you want to write some code that executes when a page loads, you have two options:
Put the code into a control and drop the control on a page created from within Sitefinity
Create a regular ASPX page from Visual Studio and include it as an external page in Sitefinity.
I would recommend the first option, as this would provide you with all the Sitefinity goodness that all pages use - templates, editing through the browser, etc.
If you wanted something else and I misunderstood, please be more specific.
Slavo, The Sitefinity Team

Categories