When I view an ascx file from Sitecore File Manager and it displays something like CodeBehind="Promo Downloads.ascx.cs in the header, but It doesn't seem to exist. There is an asp:Literal control I'm trying to figure out where it's coming from.
Asked
Active
Viewed 1,084 times
0
-
1Generally, the code is compiled before being placed on the site and therefore, the `.cs` files won't be accessible via the file explorer. All the code has been compiled into a DLL file. If you have access to the source code, you'll need to find the `Promo Downloads.ascx.cs` there. If you don't have access to the source code for some reason, you can use a tool like dotPeek or JustDecompile and load up your project DLL, and then find the code for the `Promo Downloads` class there. – Amir Setoudeh Jul 21 '15 at 21:10
1 Answers
2
.cs files are compiled into a dll and will/shouldn't be available in the Sitecore solution using the code behind model. This only happens if you use the old code file model.
If you want to see the code for this then you'll need to view the original source code or decompile the dll.
To decompile the URL: The dll will be in the /bin folder. To find out which dll, look at the namespace in the .ascx file - the name of the dll should be the first part of the namespace.
Once you've found the dll, use dotpeek https://www.jetbrains.com/decompiler/ to examine the code.

Ian Graham
- 3,206
- 1
- 15
- 23
-
This was very helpful. Thank you very much. Now I just want to duplicate the ascx file and alter a small bit of code in the .cs(decompiled from the .dll). What is the best way to do this. I'm not familiar with compiling. Would I need to create my own .dll and include it in the bin folder? – leflis Jul 22 '15 at 12:54
-
It would be best for you to create a new dll. Create a new visual studio empty web project, add a new ascx file to the solution. Copy the markup from the existing ascx file and place in this ascx, add the code behind code from the decompiler and add to the ascx.cs file. Make sure the namespace declarations are the same in the ascx and cs. You'll probably need to add references to the Sitecore.Kernel.dll in the project to make it build. Once it is built you can copy the dll to the bin folder and register a new sublayout in Sitecore – Ian Graham Jul 22 '15 at 13:15
-
If you're not familiar with c#, visual studio and Sitecore it might be a steep learning curv , but follow the instructions above. – Ian Graham Jul 22 '15 at 13:17