The name Repeater1 does not exist in the current content - c#

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

Related

Parse Error While Opening a dynamic Page

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 :)

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.

Validation of ViewState MAC Failed

Sorry if this is duplicate but I've been going crazy for the past two hours over this.
After changing the Master Page in ASP.NET MVC 1.0 application, I keep getting this familiar error when I try a postback without filling in the mandatory form elements which are validated by the server:
"Validation of viewstate MAC failed.
If this application is hosted by a Web
Farm or cluster, ensure that
configuration specifies
the same validationKey and validation
algorithm. AutoGenerate cannot be used
in a cluster."
The new page refers to a lot of jQuery code with lightboxes, superfish etc. Could that be a problem while doing a postback?
If I revert back to the original master, the error disappears and I'm able to validate form fields. Both masters are located in the same path.
I know a lot of other guys have faced this issue but I was unable to find anything which could help me.
Thanks.
Edited and added
After a little debugging, I've realized that a directive in the master page:
<% Html.RenderAction("menu", "nav"); %>
is creating the problem. The directive asks the "menu" action of the controller "nav" to inject a partial view Menu.ascx. If I delete this line from the new master page, everything works OK. My app's left bar navigation relies on this directive to work properly. Is there any way I can get around this? Very mysterious.
Are you using Html.AntiForgeryToken() anywhere on this page? Sometimes when I am testing locally with multiple different sites and / or port changes this will happen to me. If it does I clear my browser cache and it works just fine.
I did experienced the same problem two days ago. :)
A simple restart of the box has worked in my case so I did'nt investigate further.

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

sharepoint error when creating a page

I got this error message when i want to create a page in the SharePoint Central Administration :
The base type 'xxxx' is not allowed for this page. The type is not registered as safe.
The .aspx page references a codebehind class. I checked the namespaces, i added the tag in the web.config, everything is fine, but it still doesn't work !
Can someone please tell me why i got this error message ?
Registering controls as safe via direct web.config is a method that will work, however things get complex when you have a farm. If you have a farm you will have to do this in every web.config for every WFE server you have. The preferred way is doing this via solution package, which is what we do in our environment. See this article which helped us.
Is the entry in the SafeControls correct? Does it reference the exact version number of the assembly? Is the public key token correct?
The one thing that often gets me into toruble is the namespace. Use .NET Reflector and open your assembly - navigate to the control and look at the namespace path for that control in the bottom left of the screen. Sometimes I put the name of the control in SafeControls with the wrong namespace path.

Categories