after renaming the page everything works fine. - asp.net

we are facing a strange issue. we have a (custom)file upload control in our page . which binds files to a grid view. say our page name is xxx.aspx. our custom file upload control works fine every where except xxx.aspx. when we attach files on xxx.aspx it does not show files in grid although grid view contains the attached file in it(on server side) but is not rendering on client side. (its out side of an update panel, so its not an ajax problem).
if we rename the page to something else, say "aaa.aspx", it starts working fine.
so there is something with the xxx.aspx.
what it could be ? any idea?

try checking your header on aspx and class on server side
cause when you just rename your asp page the code doesnt change itself so you have to rename also
like this
<%# Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false"
CodeFile="xxx.aspx.vb" Inherits="xxx" Title="Untitled Page" %>
and on your server side
Partial Class xxx
end class
get my point?

Related

How can I add a code-behind file to an aspx page?

There are two pages in a legacy app to which I'm addding fuctionality.
One of the .aspx files, when the "Design" view is shown, sports an Events tab in the Properties pane:
The other, though, does not - it only shows Properties:
I need to add a custom method to this code; how can I create a corresponding .vb code-behind file where I can add this method?
UPDATE
I tried jackjop's suggestions, but F7 did nothing, and I do not seem to have the "Show All Files" glyph:
UPDATE 2
I tried adding this to the top of the .aspx file, mirroring what is in the aspx/aspx.vb pair that works as I want, but it didn't seem to make any difference:
<%# Page Language="VB" AutoEventWireup="true" CodeFile="custmaint_entry.aspx.vb" Inherits="pages_custmaint_entry" %>
When you create an ASPX file it also creates a code-behind file. You just can't see it.
From aspx file press F7 or click Show All Files button in Solution Explorer.
Notice that when Show All Files is not clicked, it doesn't show code behind files.
Or you can just simply right-click on aspx file on Solution Explorer and click View Code. If this also does not work, then you probably deleted the code behind files, I suggest you re-creating every file.

Copied page designer file reverting to original class name

I needed to make a new page which was very similar to another so I simply copied it and renamed both the file and the class name within the code.
So far so good.
However, if I make a change to the markup, the designer file in the new page forgets the new class name and reverts to the old one causing compile errors.
It is easy enough to fix but is there some way of making the change stick rather than having to do this each time?
Also, should I have cloned the page a different way?
Well, I thought this was just a feature but when I ran the new page it routed to the old one.
On inspection, the problem was this line:
<%# Page Language="vb" AutoEventWireup="false" Codebehind="WibbleNew.aspx.vb" Inherits="Wibble"%>
I had changed the Codebehind section but not the Inherits, so it should have been:
<%# Page Language="vb" AutoEventWireup="false" Codebehind="WibbleNew.aspx.vb" Inherits="WibbleNew"%>
I did say it had been a while... :-/
You could put the common features in a master page and then just create separate pages for the two sets of differences.
There is a good intro to that here: http://www.w3schools.com/aspnet/aspnet_masterpages.asp

Visual Studio 2010 BreakPoints not hit on one page but hit on the other

I have a project I inherited on only one of the pages the break points are not being hit. They are not hollow, they are solid and look as if they are going to be hit when I run the code, but when the page loads (one of the break points) it does not break. Now I added a break point to a different page (onLoad) and it does it. I have never come across this before, does anyone one have any insight on this crazy visual studio behavior?
I have tried to clean and rebuild the project and still not working.
aspx page:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Screener.aspx.cs" Inherits="Screener.Screener" %>
.cs page:
namespace Screener
{
public partial class Screener : System.Web.UI.Page
One thing I just noticed, the code behind page is 1633 lines long, should that matter?
I just deleted the old page and re-created it and still nothing.
There is another way to force a breakpoint (in code)
Add the System.Diagnostic namespace to your code behind
add an additional line of code Debugger.Break();
This will force the debugger to break (if running) otherwise a dialog box will appear asking to debug. Should identify if this is an issue with visual studio caching something or the code that you wish to debug is not being called.
Do not forget to remove from code when done.
http://msdn.microsoft.com/en-us/library/system.diagnostics.debugger.break(v=vs.110).aspx

Response.Redirect and HTML content

I have a Web Form whose sole purpose is to redirect to other pages. I created it as a normal aspx page and then I deleted everything in the .aspx file and kept just the first line shown below--even the Doctype and HTML tag are gone now:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Redirect.aspx.cs" Inherits="Web.Redirect" %>
I also deleted the .designer.cs file as it contained nothing. It works, but I wonder if what I did is right. Are there any concerns about removing all HTML content from the Web Form in this case?
None whatsoever. What you have done is perfectly acceptable.
However, if the sole purpose of the pages is to redirect, I would use a Handler/ASHX file as it can be used in exactly the same way and doesn't have as much overhead as the ASPX page.
Here is a description and example of how to use one.
If you do Response.Redirect(url), a redirect header is added and the request is ended. This means that anything in your ASPX page is not output to the client. Any content after Response.Redirect(url) is not output to the page. You can just as well delete it, like you did.
If you do Response.Redirect(url, false), the response is not ended and your page is output to the client. However, the client never gets to see it because he is redirected.

Visual Studio creation of WebForms vs Blank Files

When trying to write the codebehind file for its associates aspx page a colleague and I were stumped as to why the Controls within file.aspx were not appearing in the codecompletion, nor were they compiling without error.
When i created the file.aspx and file.aspx.cs I had created these items as blank files, the file.aspx.cs build action was set to Compile while the file.aspx Build Action was Content.
We created a new "webform" item that automatically generated the SecondFile.aspx and the SecondFile.aspx.cs file and associated them. We copied the HTML and code from file to SecondFile and the code completion worked, and the codeBehind compiled correctly.
Why?
You have not included enough information, but I think you might have forgot to put the page declaration at the top of your .aspx file
<%# Page Language="C#" CodeFile="file.aspx.cs" Inherits="my_ascx_class_name" %>

Resources