c# - Asp.Net - UserControl - Inherit from MasterPage -


Is it possible to do something like a user with a masterpiece for a user control (SSCX)?

My issue is in one of my user controls (use only one type of masterpiece), I have a & lt; Asp: content & gt; I would like to use the tag, but I can not, in the page that I only use that user control ...

Therefore, I have to repeat some code in every page that will Uses user controls ...

Update

For example, every time, I need to add something like this:

  & Lt; Asp: Content ID = "cntJavascript" ContentPlaceHolderID = "cphJavascript" runat = "server" & gt; & Lt; Script type = "text / javascript" src = "& lt;% = Url.Content (" ~ / content / js / ucjs.js ")%>" & Gt; & Lt; / Script & gt; & Lt; / ASP: Content & gt;  

So, I want all my JPS files in my masterpace in the same place and I only want to add JS

I think the answer you're looking for using the Page.RegisterClientScriptInclude in each control to use the code code To do this, using the same key value each time.

In this way, the Javascript file will only be included once, no matter how many controls are required.

  Internal Fixed Zero RegisterJavascriptInclude (page page, string included file) {string key = includeFile.ToLowerInvariant (); If the (Includes the classic script.is client scripts (registered) (registered) (page).}  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -