when do you need .ascx files and how would you use them?

后端 未结 7 945
攒了一身酷
攒了一身酷 2020-12-07 15:27

When building a website, when would it be a good idea to use .ascx files? What exactly is the .ascx and what is it used for? Examples would help a lot thanks!

相关标签:
7条回答
  • 2020-12-07 16:06

    We basically use user controls when we have to use similar functionality on different locations of an app. Like we use master pages for consistent look and feel of app, similarly to avoid repeating the same functionality and UI all over the app, we use usercontrols. There might me much more usage too, but I know this one only...

    For example, let's say your site has 4 levels of users and for each user there are different pages under different directories with different access mechanisms. Say you are requesting address info for all users, then creating address fields like Street, City, State, Zip, etc on each page. That would be a repetitive job. Instead you can create it as an ascx file (ext for user control) and in this control put the necessary UI and business code for add/update/delete/select the address role wise and then simply reference it all required page.

    So, thought user controls, one can avoid code repetition for each role and UI creation for each role.

    0 讨论(0)
提交回复
热议问题