Beispiel #1
0
        private void EnsureMasterPageFileFromConfigApplied()
        {
            // Skip if it's already applied.
            if (_mainDirectiveMasterPageSet)
            {
                return;
            }

            // If the masterPageFile is defined in the config
            if (_configMasterPageFile != null)
            {
                // Readjust the lineNumber to the location of maindirective
                int prevLineNumber = _lineNumber;
                _lineNumber = _mainDirectiveLineNumber;
                try {
                    if (_configMasterPageFile.Length > 0)
                    {
                        Type type = GetReferencedType(_configMasterPageFile);

                        // Make sure it has the correct base type
                        if (!typeof(MasterPage).IsAssignableFrom(type))
                        {
                            ProcessError(SR.GetString(SR.Invalid_master_base, _configMasterPageFile));
                        }
                    }

                    if (((FileLevelPageControlBuilder)RootBuilder).ContentBuilderEntries != null)
                    {
                        RootBuilder.SetControlType(BaseType);
                        RootBuilder.PreprocessAttribute(String.Empty /*filter*/, "MasterPageFile", _configMasterPageFile, true /*mainDirectiveMode*/);
                    }
                }
                finally {
                    _lineNumber = prevLineNumber;
                }
            }

            _mainDirectiveMasterPageSet = true;
        }
        internal override void ProcessUnknownMainDirectiveAttribute(string filter, string attribName, string value)
        {
            // Don't allow the id to be specified on the directive, even though it is
            // a public member of the control class (VSWhidbey 85384)
            if (attribName == "id")
            {
                base.ProcessUnknownMainDirectiveAttribute(filter, attribName, value);
                return;
            }

            // Process unknown attributes as regular control attribute, hence allowing
            // arbitrary properties of the base class to be set.
            // But turn off IAttributeAccessor support, otherwise any bad string on a
            // user control's directive won't be caught.

            try {
                RootBuilder.PreprocessAttribute(filter, attribName, value, true /*mainDirectiveMode*/);
            }
            catch (Exception e) {
                ProcessError(SR.GetString(SR.Attrib_parse_error, attribName, e.Message));
            }
        }