Issues with code behind generation - c#

For some odd reason, I can't get my page's code behind to generate, the file has been created but none of the controls seem to be getting generated in..
There are no warnings/errors coming from VS when I am trying to generate this file, this has worked in the past but suddenly it stopped working and as far as I know nothing has changed apart from I have installed .NET Demon which I have tried disabling fully but this doesn't appear to change it.
I have spent a good few hours looking into this issue and all I have found in terms of solutions is to delete the .designer.cs file and then converting the .aspx file to a web application but this does not fix my issue. I have also tried to recreate the page but no luck either, I will put below a few bits of code that may help.
Generated file namespace:
namespace Web.admin.reports {
<%# Page Language="C#" Inherits="Web.admin.reports.productpromotionsummary" Title="Promotions Summary" CodeBehind="~/admin/reports/productpromotionsummary.aspx.cs" AutoEventWireup="True" %
If you need anymore information please feel free to ask

Related

Changes in a copy of the master aspx file not being seen

I am attempting to make some changes to an asp.net website at short notice. In order to work on these without affecting the live site I have made a test copy of both the index.aspx file and the Site_Main.Master file. I have done this in the past without problems (I think, though I am starting to question myself).
The copies of the files are named index_test.aspx and Site_Main_test.Master respectively.
In the index_test.aspx file I have updated the MasterPageFile field accordingly...
<%# Page Language="C#" Debug="True"
MasterPageFile="~/MasterPages/Site_Main_test.Master"
AutoEventWireup="true"
CodeBehind="index.aspx.cs"
Inherits="EWS.L2B.Web.Index" %>
When I visit index_test.aspx in the browser it works fine, telling me I have succesfully set up the conditions to work on test versions of the files.
The problem is when I start to make changes in Site_Main_test.Master it doesn't seem to be 'seeing' those changes.
So in order to debug this issue, I put a simple Response.Write("<!-- Test -->"); near the top of the Master file. No sign of that in the page response when visiting index_test.aspx in the browser.
Scratching my head, I decide to risk putting the same in the original Site_Main.Master file, and load the index.aspx in the browser. The <!-- Test --> comment shows up!
I am fully aware this is probably an unrecommended way of working on an asp.net website but I don't have time to figure out another way to do this.
I can't figure out why changes to the original Master file are immediately apparent, whereas changes in the test copies seem to be being ignored. Any help would be appreciated.
(As another troubleshooting test I deliberately broke Site_Main_test.Master, which does generate an error when I visit index_test.aspx, which tells me it is at least picking up the copy of the Master file)

In VS 2019 - How to regenerate code-behind and designer files from an existing aspx page

I imported in my project Web c# an aspx page, for example, mypage.aspx, with HTML code. This page is very simple.
All I want is to generate the 2 files (in IDE) aspx.cs and designer.cs (mypage.aspx.cs and mypage.aspx.designer.cs).
I tried "Convert to web project" functionality but it does not work.
Any idea, please?
Of course, I read several solutions on this site but none worked (with vs 2019).
If there is no actual code in the original code-behind file then it's pretty easy to do. Create a new page of the same name. Then just copy and paste the markup from the original, taking care to leave the newly-created page directive as is.
If there was logic in your original code-behind then you're out of luck. You might try decompiling the original DLL and try to re-create the original code that way.

css is lost on postback

I currently have a problem with my website in ASP.net / C#. I'm building a page, where a couple of elements are dependent on others. On this page I use some import css classes, though they seem to get lost, whenever a Postback happens. Could anyone take a look at the code and tell me where it goes wrong?
I used a .NET fiddle file to paste the code of my .ascx and .ascx.cs file. I hope it's somewhat clear. Apologies if it's not.
https://dotnetfiddle.net/NLwtiN
EDIT: I tried to compare the html of 2 DropDownLists, hoping there'd be some significant difference, though there is next to none

Inherited an ASPX site and cannot change a variable

I just inherited an ASPX site from a new customer of mine. I know ASP but I cannot figure this one out. There are two pages that seemingly do exactly the same thing (cause they should) they both read an XML file and pull in the correct child datasets 2010 for the 2010 data and 2011. I need to add a new set for their 2012 line.
I figured I could dupe one of these pages and change the "2011" to "2012." The problem is I cannot find the "2011" ANYWHERE! the only difference between the two files is:
There isn't a "year2011.aspx.cs" to be found via FTP that I can see and changing the 2011 to 2012 just throws an error. Reading up a little on the CodeBehind tag there pointed me to a few DLLs that ARE there BUT I have no idea how to edit them to make them work. Their old developer did not leave anything but what was on the server.
Any ideas on what I can do to make this work?
It seems the code is compiled so there wont be any *.cs files. If you haven't got the source code as you have mentioned you will need to decompile the DLL's to allow you make any necessary edits.
Take a look at http://www.telerik.com/products/decompiler.aspx , it will allow to decompile the dll back to *.cs files to allow you to make any edits.
Once you have the source code you should be able to debug and provide more information about the error you are experiencing

Broken link between aspx and aspx.cs files

I've had the same problem a couple of times with different ASPX pages after renaming them and I am surprised that I can't find someone else with the same problem on stackoverflow.
When I run my ASP.NET C# project, the debugger gives me a message like this one.
Error 5 The name 'txtTitle' does not exist in the current context
It seems that the aspx and aspx.cs files at no longer bound. The only fix I have found for this is to recreate the page and copy/paste my code.
Any idea how to fix this without recreating the whole thing?
Thanks
The code file contains a partial class that is referenced in the ASPX header declaration. Both file name and the actual class in the ASPX header have to match for this to work.
<%# Page Title="TestPage" Language="C#" AutoEventWireup="true" CodeFile="TestPage.aspx.cs" Inherits="TestPage" %>
In your case probably the class name does not match. Check if the class name in the codebehind .cs file matches the name after Inherits.
The concept of partial classes used in ASP.NET is detailed here.
I am surprised at this occurring I regularly rename Silverlight user controls with no harmful side-effects.
Are all of the references to classes being renamed in the aspx page and code behind ?
You might try using this util to relink them.
This can also be caused by the whatever.aspx.designer.vb file being dependent upon whatever.aspx.vb instead of whatever.aspx. If this is the case, it should show incorrectly in the file tree when you expand the group of files in Visual Studio. To fix it, simply exclude the affected files from the project and then re-include them - the faulty project config file should be regenerated and it should now work correctly.
(Same theory for C#.)
I've had the same problem and noticed that sometimes, but not always, the CodeFile setting in the .aspx page is not updated when the class is changed. If this is the same problem you have, you can change it manually:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="MyClass.aspx.cs" Inherits="MyClass" %>
^^^^^^^

Categories

Resources