What Is an ASCX File?

Microsoft's free Visual Studio software can open ASP.NET Web User Control files

What to Know

  • ASCX files are ASP.NET Web User Control files that can be opened with Visual Studio.
  • Designed for web development, these are used to create similar functionality across different locations of an app.

This article explains what an ASCX file is and how to open or convert one.

What Is an ASCX File?

A file with the ASCX file extension is an ASP.NET Web User Control file that stands for Active Server Control Extension.

Basically, ASCX files make it easy to use the same code across multiple ASP.NET web pages, saving time and energy when building a website.

For example, a number of ASPX files on a website might link to a single ASCX file that contains code for the site's navigation menu. Instead of writing the same code on every page of the website that needs the menu, each page can just point to the ASCX file, making managing and updating the menu on every page much easier.

Considering how effective ASCX files are at simplifying ASP.NET programming, these files are often used for other consistent parts of a website, like headers, footers, etc.

ASCX files in Windows 10 used with Adobe Dreamweaver

If you know your ASCX file has nothing to do with an ASP website, like if you downloaded one by accident while trying to get a bank statement or some other document, then you should treat it differently than a real ASP.NET user control file (more on that below).

How to Open an ASCX File

Microsoft's Visual Studio can open and edit ASCX files, as well as Adobe's Dreamweaver. If you need to open one on a Mac, TextMate should work.

Although an ASCX file is linked from inside an ASPX file (which can be viewed in a browser), the ASCX file itself isn't intended to be opened by the browser. If you've downloaded an ASCX file and expected it to contain information (like a document or other saved data), it's likely that something is wrong with the website and instead of generating the usable information you were after, it provided this server-side file instead.

If that happens, try downloading the file again or even just renaming the file to use the extension you expected it to be. Sometimes that works.

For example, if you intended on downloading a PDF file but were given an ASCX file instead, just rename the ASCX part of the file to PDF, like file.ascx to file.pdf.

Renaming a file to use a different extension is not the same as converting the file to a new format. In this case, you're just properly renaming the file to its actual format (PDF in this example), something the website should have done but didn't fully complete for some reason. This allows the OS to recognize which program should be used to open the file (like a PDF reader).

How to Convert an ASCX File

A file converter is usually the recommended tool for converting most types of files, like videos, music file, images, documents, etc.

However, converting a file like an ASCX file to something else will break its functionality, so it probably isn't something you want to do, especially if the file is being hosted online and is otherwise working just fine.

For example, changing a working file with the .ASCX file extension to anything else means that all the ASPX files that are pointing to that ASCX file will cease to understand what the file is for, and therefore won't understand how to use its contents to render menus, headers, etc.

However, the opposite conversion might actually be something you're interested in. A number of manual changes are required to convert an ASPX page to an ASCX file, so be sure to follow Microsoft's instructions very carefully.

Microsoft has another tutorial on turning an ASCX file into a Redistributable Custom Control (a DLL file). If you know anything about DLL files, you may have already realized that ASCX files behave very much like the shared DLL files on your Windows computer.

More Information on ASCX Files

ASCX files and ASPX files are made up of very similar code, but Web User Control files don't contain any html, body, or form elements.

Microsoft's how-to on creating ASP.NET user controls explains the steps it takes to create an ASCX file, and Bean Software has some good examples on how to add Web User Control files to an ASP.NET page.

Still Can't Open the File?

If after trying the above programs, your file still won't open properly, there's a good chance you're not really dealing with an ASCX file. Some file formats use a file extension that closely resembles this one, even though the formats aren't related.

For example, ACX files might look like they're related in some way to ASCX files, but those are actually Atari ST Program files that can be used on a computer with an Atari ST emulator like Gemulator. They will not open with an ASCX file opener.

The same concept holds true for other files like ACSM, ASAX, and ASX files. If you have one of those files, or any other file that simply looks like an ASCX file, research its real file extension to learn which programs can open or convert it.

ASHX files are similar to ASCX files, but are ASP.NET Web Handler files.

FAQ
  • How do I include a CSS file in an ASCX file?

    You can add CSS inline, using the style attribute inside HTML elements; internally, using a <style> element in the <head> section; or externally, including a <link> element to link to an external CSS file.

  • How do you add an ASCX file in ASP.NET?

    On the Website menu, go to Add New Item > Web User Control. Enter a name for the control, select the programming language you want to use, and click Add. By default, the .ascx file name extension is added to the control name.

  • How do you add a comment in an ASCX file?

    Select the lines you want to be commented and choose Comment/Uncomment in the toolbar. Alternatively, press Ctrl+K and then Ctrl+C to comment, and Ctrl+K and then Ctrl+U to uncomment.

Was this page helpful?