Parse Error While Opening a dynamic Page - c#

This is my first post here. I am doing a college project and I am stuck in an error.
I am building an e-learning website in ASP.net and they are static pages. Now, when I am opening a contact-us form it is throwing me an error.
Error Page
Contact us form is in another folder.
Link page
I am a noob :( Please explain me in easy way.

enter code hereThe error you are getting means that there is no file called default.aspx.cs in the same directory as your default.aspx file.
Please make sure that this file exists.
You may have deleted it, or moved it to a different location.
Your IIS is trying to link the default.aspx.cs, which is the code file, to the default.aspx file, which is your HTML file, which uses the code.
You can see the link between the files at the top level declarations in your ASPX file:
"Codefile = default.aspx.cs"
If you cannot file the default.aspx.cs file, I suggest you re-create the ASPX file using your development editor. This will create the default.aspx.cs file automatically under your ASPX file.
From MSDN:
The code-behind page model for Web Forms allows you to keep the markup
in one file—the .aspx file—and the programming code in another file.
The name of the code file varies according to what programming
language you are using. For example, if you are working with a page
named SamplePage, the markup is in the file SamplePage.aspx and the
code is in a file named SamplePage.aspx.vb (for Visual Basic) and
SamplePage.aspx.cs (for C#).
Hope this helps.

Well! The issues was I didn't selected the C# and my project was on vb. This is the reason why it thrown me that error.
If this error comes we need to make sure what files we are having and in which language we are making project :)

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?

Can people find and download the Code File linked to your aspx page?

So I imported this aspx page done by a former dev who worked for the company I'm in now. I found that the aspx page left by him doesn't have a codebehind file so I assumed this wasn't the source code. I can't find the source so I added a code file and try to work it out on my own. But my main concern is this: clients can't access the code behind, right? Is a manually added code file subject to the same protection?
The codebehind file is there as a place to put your server side code. However it's technically not necessary to have one since you can put the code in the aspx file using c# script tags. It's however recommended to put it in the codebehind file for better separation between markup and code.
It does not matter if you add it yourself or if Visual Studio adds it for you. It does not change anything in terms of access. In all events it executes on the server.
If your server is properly configured to run ASP.NET applications - which I believe it is - then IIS will not serve .cs files to a client. These will normally be accessible only through FTP. Try it yourself, by browsing to any .cs file in your application :)
Also notice that what you get when you browse to an .aspx file is not the very same code you'd see in Visual Studio, but the result of that being processed. IIS will serve the resulting HTML. So even if you have server side code in the ASPX file, that won't be visible to an end user browsing through your application.
Sounds like a web application project; in this case, the code is in the code-behind file as #TGH mentioned, and the code would be in the DLL compiled for the web application. Therefore, the only way to get that code is use a tool like Telerik JustDecompile, and decompile that DLL to grab the source code for EVERY file in the project. It would be much better to have the source, as these decompile tools do not include everything in that code-behind file.

The name Repeater1 does not exist in the current content

Im using a masterpage on asp.net c# for the website. (And created an aspx page related to the master page, by hand, not automatically)
I put a repeater control to the page.
Then I couldn't reach to the control by name in codebehind.
The compiling error is : 'The name Repeater1 does not exist in the current content'
Can you please point out my mistake?
Sometimes the designers get out of sync with the aspx pages. When such a thing occurs, the code behind files become unable to access controls that you have added to your aspx pages and you'll get errors like the one you received.
You can get around this error by regenerating the designer file, as you said Project -> Convert to web application is one way to do it.
One last thing, not sure what version of VS you're using, or if this will help, but there was a hotfix released for VS2010 that is supposed to take care of some occurrences of this problem.
http://blogs.msdn.com/b/webdev/archive/2010/03/05/hotfix-for-issue-with-auto-generated-designer-files-not-adding-controls.aspx

Run a aspx page into a Sharepoint folder

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.

Make sure that the class defined in this code file matches the 'inherits' attribute,

Sometimes in my web applications I used to get this sort of error, I have no clue why is it coming however if I refresh the page few times the page is loading normally.
I am using .net framework 2.0 and visual web developer 2005.
I have only ever seen this error message when the class that is contained in your file is diffrent from the class being called in the HTML page
For example at the top of your html page there will be a line of code that goes something like this:<%# Page Language="C#" AutoEventWireup="true" CodeFile="#whereyourcodeis.aspx.cs" Inherits="#ClassName" Title="whatever" %>
and in your whereyourcodeis.aspx.cs file there should be a constructor method that has the same name as the inherits line in your html. ie Class ClassName{ rest of your code}
If for some reason these two names do not match you get the error you have, hope this can shine some light on where your code is going wrong
It happened to me when by accident I changed the codefile of another aspx file to point to the same code file as the current page file.
Make sure each aspx file point to the correct code file. Visual studio doesn't point you to the right file.
You can try and search the name of the file that causes the error to find the other page pointing to it.

Categories