Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Dynamically add page directive.

Posted on 2013-12-04
Medium Priority
Last Modified: 2013-12-07
Is there away to Dynamically add this to a page, either using web.config, or code behind:  

<%@ Master Language="vb" AutoEventWireup="false"  CodeFile="TaborModalPopup.master.vb" Inherits="Tabor.UI.TaborModalPopup" %>
Question by:HLRosenberger
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 27

Expert Comment

by:Chinmay Patel
ID: 39696229
Which directive you need to add? the entire markup? I don't think that's something that you can do within boundaries of ASP.Net?

Can you throw some light on what exactly you are trying to achieve?

Author Comment

ID: 39696356
I need to add CodeFile and Inherits.  I'm using a Third-Party product that generated code.  Problem is there is no "hook" so to speak to add the directives.  So each time I regenerate, my directives are gone.
LVL 27

Expert Comment

by:Chinmay Patel
ID: 39696375
Hmmm I don't think it is possible during the runtime. You might want to write a little utility that can change these directives for you. Does that third party product has support to include these directives?

I could be wrong here but as long as I know there is no way to dynamically do this during the runtime.
LVL 11

Accepted Solution

SAMIR BHOGAYTA earned 2000 total points
ID: 39700316
You can set the MasterPageFile Property from Code

Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit Me.MasterPageFile = "~/Site.master"
End Sub

Protected Overrides Sub OnPreInit(ByVal e As System.EventArgs)
Me.MasterPageFile = "~/Site.master" MyBase.OnPreInit(e)
End Sub

Author Closing Comment

ID: 39703500

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question