private static string RenderIncludes(HtmlHelper html, Type includeAttributeType, IUrlResolutionService urlResolver, string format, params object[] attributedObjects)
        {
            var includeUrls = new List <string>();

            foreach (var attributedObject in attributedObjects)
            {
                foreach (var includeAttribute in attributedObject.GetType().GetCustomAttributes(includeAttributeType, true).Cast <IncludeAttribute>())
                {
                    foreach (var url in includeAttribute.Urls)
                    {
                        var resolvedUrl = urlResolver.ResolveClientUrl(url);

                        if (!includeUrls.Contains(resolvedUrl))
                        {
                            includeUrls.Add(resolvedUrl);
                        }
                    }
                }
            }

            var includesBuilder = new StringBuilder();

            foreach (var url in includeUrls)
            {
                includesBuilder.AppendFormat(format, url);
            }

            return(includesBuilder.ToString());
        }
Пример #2
0
 public static void docFileUploadComplete(object sender, FileUploadCompleteEventArgs e)
 {
     if (e.UploadedFile.IsValid)
     {
         string resultFilePath = HttpContext.Current.Request.MapPath(DocUploadDirectory + e.UploadedFile.FileName);
         try
         {
             e.UploadedFile.SaveAs(resultFilePath, true); //Code Central Mode - Uncomment This Line
             Session["uploadedFile"] = e.UploadedFile;
             IUrlResolutionService urlResolver = sender as IUrlResolutionService;
             if (urlResolver != null)
             {
                 e.CallbackData = urlResolver.ResolveClientUrl(resultFilePath);
             }
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
     else
     {
         throw new Exception(e.ErrorText);
     }
 }
Пример #3
0
        public static void ucMultiSelection_FileUploadComplete(object sender, FileUploadCompleteEventArgs e)
        {
            string resultFileName = Path.GetRandomFileName() + "_" + e.UploadedFile.FileName;
            string resultFileUrl  = UploadDirectory + resultFileName;
            //Custom host show file
            string hostFileUrl    = LocalHost + resultFileName;
            string resultFilePath = HttpContext.Current.Request.MapPath(resultFileUrl);

            e.UploadedFile.SaveAs(resultFilePath);

            //UploadingUtils.RemoveFileWithDelay(resultFileName, resultFilePath, 5);

            IUrlResolutionService urlResolver = sender as IUrlResolutionService;

            if (urlResolver != null)
            {
                string url = urlResolver.ResolveClientUrl(hostFileUrl);
                e.CallbackData = GetCallbackData(e.UploadedFile, url);
            }
            if (System.Web.HttpContext.Current.Session["URL"] == null)
            {
                System.Web.HttpContext.Current.Session["URL"] = resultFilePath;
            }
            else
            {
                System.Web.HttpContext.Current.Session["URL"] += '|' + resultFilePath;
            }
        }
        protected override void AddDesignTimeCssAttributes(IDictionary styleAttributes)
        {
            Panel component = (Panel)base.Component;

            switch (component.Direction)
            {
            case ContentDirection.LeftToRight:
                styleAttributes["direction"] = "ltr";
                break;

            case ContentDirection.RightToLeft:
                styleAttributes["direction"] = "rtl";
                break;
            }
            string backImageUrl = component.BackImageUrl;

            if (backImageUrl.Trim().Length > 0)
            {
                IUrlResolutionService service = (IUrlResolutionService)this.GetService(typeof(IUrlResolutionService));
                if (service != null)
                {
                    backImageUrl = service.ResolveClientUrl(backImageUrl);
                    styleAttributes["background-image"] = "url(" + backImageUrl + ")";
                }
            }
            switch (component.ScrollBars)
            {
            case ScrollBars.Horizontal:
                styleAttributes["overflow-x"] = "scroll";
                break;

            case ScrollBars.Vertical:
                styleAttributes["overflow-y"] = "scroll";
                break;

            case ScrollBars.Both:
                styleAttributes["overflow"] = "scroll";
                break;

            case ScrollBars.Auto:
                styleAttributes["overflow"] = "auto";
                break;
            }
            HorizontalAlign horizontalAlign = component.HorizontalAlign;

            if (horizontalAlign != HorizontalAlign.NotSet)
            {
                TypeConverter converter = TypeDescriptor.GetConverter(typeof(HorizontalAlign));
                styleAttributes["text-align"] = converter.ConvertToInvariantString(horizontalAlign).ToLowerInvariant();
            }
            if (!component.Wrap)
            {
                styleAttributes["white-space"] = "nowrap";
            }
            base.AddDesignTimeCssAttributes(styleAttributes);
        }
 // Token: 0x060000BD RID: 189 RVA: 0x00003529 File Offset: 0x00001729
 public static void AddUrlProperty(this ScriptComponentDescriptor descriptor, string name, string value, IUrlResolutionService urlResolver)
 {
     if (!string.IsNullOrEmpty(value))
     {
         if (urlResolver != null)
         {
             value = urlResolver.ResolveClientUrl(value);
         }
         descriptor.AddProperty(name, value);
     }
 }
Пример #6
0
 public static void FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
 {
     if (e.UploadedFile.IsValid)
     {
         string resultFilePath = HttpContext.Current.Request.MapPath(UploadDirectory + e.UploadedFile.FileName);
         e.UploadedFile.SaveAs(resultFilePath, true);
         IUrlResolutionService urlResolver = sender as IUrlResolutionService;
         if (urlResolver != null)
         {
             e.CallbackData = urlResolver.ResolveClientUrl(resultFilePath);
         }
     }
 }
 public static void uploadControl_FileUploadComplete(object sender, FileUploadCompleteEventArgs e)
 {
     if (e.UploadedFile.IsValid)
     {
         string resultFilePath = "~/Content/Avatars/" + string.Format("Avatar{0}{1}", Convert.ToString(HttpContext.Current.Session["UserID"]), Path.GetExtension(e.UploadedFile.FileName));
         e.UploadedFile.SaveAs(HttpContext.Current.Request.MapPath(resultFilePath));
         IUrlResolutionService urlResolver = sender as IUrlResolutionService;
         if (urlResolver != null)
         {
             e.CallbackData = urlResolver.ResolveClientUrl(resultFilePath) + "?refresh=" + Guid.NewGuid().ToString();
         }
     }
 }
 public static void uc_FileUploadComplete(object sender, FileUploadCompleteEventArgs e)
 {
     if (e.UploadedFile.IsValid)
     {
         string resultFilePath = HttpContext.Current.Request.MapPath(UploadDirectory + e.UploadedFile.FileName);
         //e.UploadedFile.SaveAs(resultFilePath, true);//Code Central Mode - Uncomment This Line
         IUrlResolutionService urlResolver = sender as IUrlResolutionService;
         if (urlResolver != null)
         {
             e.CallbackData = urlResolver.ResolveClientUrl(resultFilePath);
         }
     }
 }
        protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
        {
            base.FillStyleAttributes(attributes, urlResolver);
            string backImageUrl = this.BackImageUrl;

            if (backImageUrl.Length != 0)
            {
                if (urlResolver != null)
                {
                    backImageUrl = urlResolver.ResolveClientUrl(backImageUrl);
                }
                attributes.Add(HtmlTextWriterStyle.BackgroundImage, backImageUrl);
            }
        }
Пример #10
0
 public static void uploadControl_FileUploadComplete(object sender, FileUploadCompleteEventArgs e)
 {
     if (e.UploadedFile.IsValid)
     {
         string fileName       = e.UploadedFile.FileName;
         string resultFilePath = "~/Content/FileManager/AnexosPlanTrabajo/" + fileName;
         e.UploadedFile.SaveAs(HttpContext.Current.Request.MapPath(resultFilePath));
         IUrlResolutionService urlResolver = sender as IUrlResolutionService;
         if (urlResolver != null)
         {
             e.CallbackData = urlResolver.ResolveClientUrl(resultFilePath) + "?refresh=" + Guid.NewGuid().ToString();
         }
     }
 }
Пример #11
0
 public static void ucCallbacks_FileUploadComplete(object sender, FileUploadCompleteEventArgs e)
 {
     if (e.UploadedFile.IsValid)
     {
         string resultFilePath = UploadDirectory + string.Format(ThumbnailFormat, "", Path.GetExtension(e.UploadedFile.FileName));
         using (Image original = Image.FromStream(e.UploadedFile.FileContent))
             using (Image thumbnail = PhotoUtils.Inscribe(original, 100)) {
                 PhotoUtils.SaveToJpeg(thumbnail, HttpContext.Current.Request.MapPath(resultFilePath));
             }
         IUrlResolutionService urlResolver = sender as IUrlResolutionService;
         if (urlResolver != null)
         {
             e.CallbackData = urlResolver.ResolveClientUrl(resultFilePath) + "?refresh=" + Guid.NewGuid().ToString();
         }
     }
 }
Пример #12
0
        public static void ucMultiSelection_FileUploadComplete(object sender, FileUploadCompleteEventArgs e)
        {
            string resultFilePath = UploadDirectory + e.UploadedFile.FileName;

            e.UploadedFile.SaveAs(HttpContext.Current.Request.MapPath(resultFilePath));

            UploadingUtils.RemoveFileWithDelay(e.UploadedFile.FileName, HttpContext.Current.Request.MapPath(resultFilePath), 5);

            IUrlResolutionService urlResolver = sender as IUrlResolutionService;

            if (urlResolver != null)
            {
                string file = string.Format("{0} ({1}) {2}KB", e.UploadedFile.FileName, e.UploadedFile.ContentType, e.UploadedFile.ContentLength / 1024);
                string url  = urlResolver.ResolveClientUrl(resultFilePath);
                e.CallbackData = file + "|" + url;
            }
        }
Пример #13
0
        public void UploadControl_FilesUploadComplete(object sender, FilesUploadCompleteEventArgs e)
        {
            UploadedFile[] files = ((MVCxUploadControl)sender).UploadedFiles;
            for (int i = 0; i < files.Length; i++)
            {
                if (files[i].IsValid && !string.IsNullOrWhiteSpace(files[i].FileName))
                {
                    string resultFilePath = "~/Content/" + files[i].FileName;
                    files[i].SaveAs(System.Web.HttpContext.Current.Request.MapPath(resultFilePath));

                    IUrlResolutionService urlResolver = sender as IUrlResolutionService;
                    if (urlResolver != null)
                    {
                        e.CallbackData += urlResolver.ResolveClientUrl(resultFilePath);
                    }
                }
            }
        }
Пример #14
0
 public static void ucDragAndDrop_FileUploadComplete(object sender, FileUploadCompleteEventArgs e)
 {
     if (e.UploadedFile.IsValid)
     {
         string fileName       = Path.ChangeExtension(Path.GetRandomFileName(), ".jpg");
         string resultFilePath = UploadDirectory + fileName;
         using (Image original = Image.FromStream(e.UploadedFile.FileContent))
             using (Image thumbnail = ImageUtils.CreateThumbnailImage((Bitmap)original, ImageSizeMode.ActualSizeOrFit, new Size(350, 350)))
             {
                 ImageUtils.SaveToJpeg((Bitmap)thumbnail, HttpContext.Current.Request.MapPath(resultFilePath));
             }
         UploadingUtils.RemoveFileWithDelay(fileName, HttpContext.Current.Request.MapPath(resultFilePath), 5);
         IUrlResolutionService urlResolver = sender as IUrlResolutionService;
         if (urlResolver != null)
         {
             e.CallbackData = urlResolver.ResolveClientUrl(resultFilePath);
         }
     }
 }
Пример #15
0
        public static void ucMultiSelection_FileUploadComplete(object sender, FileUploadCompleteEventArgs e)
        {
            string resultFileName = Path.GetRandomFileName() + "_" + e.UploadedFile.FileName;
            string resultFileUrl  = UploadDirectory + resultFileName;
            string resultFilePath = HttpContext.Current.Request.MapPath(resultFileUrl);

            e.UploadedFile.SaveAs(resultFilePath);

            UploadingUtils.RemoveFileWithDelay(resultFileName, resultFilePath, 5);

            IUrlResolutionService urlResolver = sender as IUrlResolutionService;

            if (urlResolver != null)
            {
                string name            = e.UploadedFile.FileName;
                string url             = urlResolver.ResolveClientUrl(resultFileUrl);
                long   sizeInKilobytes = e.UploadedFile.ContentLength / 1024;
                string sizeText        = sizeInKilobytes.ToString() + " KB";
                e.CallbackData = name + "|" + url + "|" + sizeText;
            }
        }
Пример #16
0
        protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
        {
            base.FillStyleAttributes(attributes, urlResolver);

            if (PaddingTop != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingTop, PaddingTop.ToString());
            }
            if (PaddingLeft != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingLeft, PaddingLeft.ToString());
            }
            if (PaddingRight != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingRight, PaddingRight.ToString());
            }
            if (PaddingBottom != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.PaddingBottom, PaddingBottom.ToString());
            }

            if (MarginTop != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginTop, MarginTop.ToString());
            }
            if (MarginLeft != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginLeft, MarginLeft.ToString());
            }
            if (MarginRight != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginRight, MarginRight.ToString());
            }
            if (MarginBottom != Unit.Empty)
            {
                attributes.Add(HtmlTextWriterStyle.MarginBottom, MarginBottom.ToString());
            }

            if (!String.IsNullOrEmpty(BackImageUrl))
            {
                attributes.Add(HtmlTextWriterStyle.BackgroundImage, String.Format("url({0})", urlResolver.ResolveClientUrl(BackImageUrl)));
            }
        }
        public static void DescribeComponent(object instance, IScriptComponentDescriptor descriptor, IUrlResolutionService urlResolver, IControlResolver controlResolver) {
            // validate preconditions
            if(instance == null)
                throw new ArgumentNullException("instance");
            if(descriptor == null)
                throw new ArgumentNullException("descriptor");
            if(urlResolver == null)
                urlResolver = instance as IUrlResolutionService;
            if(controlResolver == null)
                controlResolver = instance as IControlResolver;

            // describe properties
            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(instance);
            foreach(PropertyDescriptor prop in properties) {
                ExtenderControlPropertyAttribute propAttr = null;
                ExtenderControlEventAttribute eventAttr = null;

                ClientPropertyNameAttribute nameAttr = null;
                IDReferencePropertyAttribute idRefAttr = null;
                UrlPropertyAttribute urlAttr = null;
                ElementReferenceAttribute elementAttr = null;
                ComponentReferenceAttribute compAttr = null;

                foreach(Attribute attr in prop.Attributes) {
                    Type attrType = attr.GetType();
                    if(attrType == typeof(ExtenderControlPropertyAttribute))
                        propAttr = attr as ExtenderControlPropertyAttribute;
                    else if(attrType == typeof(ExtenderControlEventAttribute))
                        eventAttr = attr as ExtenderControlEventAttribute;
                    else if(attrType == typeof(ClientPropertyNameAttribute))
                        nameAttr = attr as ClientPropertyNameAttribute;
                    else if(attrType == typeof(IDReferencePropertyAttribute))
                        idRefAttr = attr as IDReferencePropertyAttribute;
                    else if(attrType == typeof(UrlPropertyAttribute))
                        urlAttr = attr as UrlPropertyAttribute;
                    else if(attrType == typeof(ElementReferenceAttribute))
                        elementAttr = attr as ElementReferenceAttribute;
                    else if(attrType == typeof(ComponentReferenceAttribute))
                        compAttr = attr as ComponentReferenceAttribute;
                }

                string propertyName = prop.Name;

                // Try getting a property attribute
                if(propAttr == null || !propAttr.IsScriptProperty) {
                    // Try getting an event attribute
                    if(eventAttr == null || !eventAttr.IsScriptEvent) {
                        continue;
                    }
                }

                // attempt to rename the property/event
                if(nameAttr != null && !string.IsNullOrEmpty(nameAttr.PropertyName)) {
                    propertyName = nameAttr.PropertyName;
                }

                // determine whether to serialize the value of a property.  readOnly properties should always be serialized
                bool serialize = prop.ShouldSerializeValue(instance) || prop.IsReadOnly;
                if(serialize) {
                    // get the value of the property, skip if it is null
                    Control c = null;
                    object value = prop.GetValue(instance);
                    if(value == null) {
                        continue;
                    }

                    // convert and resolve the value
                    if(eventAttr != null && prop.PropertyType != typeof(String)) {
                        throw new InvalidOperationException("ExtenderControlEventAttribute can only be applied to a property with a PropertyType of System.String.");
                    } else {
                        if(!prop.PropertyType.IsPrimitive && !prop.PropertyType.IsEnum) {
                            // Check if we can use any of our custom converters
                            // (first do a direct lookup on the property type,
                            // but also check all of its base types if nothing
                            // was found)
                            Converter<object, string> customConverter = null;
                            if(!_customConverters.TryGetValue(prop.PropertyType, out customConverter)) {
                                foreach(KeyValuePair<Type, Converter<object, string>> pair in _customConverters) {
                                    if(prop.PropertyType.IsSubclassOf(pair.Key)) {
                                        customConverter = pair.Value;
                                        break;
                                    }
                                }
                            }

                            // Use the custom converter if found, otherwise use
                            // its current type converter
                            if(customConverter != null) {
                                value = customConverter(value);
                            } else {
                                // Determine if we should let ASP.NET AJAX handle this type of conversion, as it supports JSON serialization
                                if(propAttr != null && propAttr.UseJsonSerialization) {
                                    // Use ASP.NET JSON serialization
                                } else {
                                    // Use the property's own converter
                                    TypeConverter conv = prop.Converter;

                                    if(value.GetType() == typeof(DateTime))
                                        value = ((DateTime)value).ToString("s", CultureInfo.InvariantCulture);
                                    else
                                        value = conv.ConvertToString(null, CultureInfo.InvariantCulture, value);
                                }
                            }
                        }
                        if(idRefAttr != null && controlResolver != null) {
                            c = controlResolver.ResolveControl((string)value);
                        }
                        if(urlAttr != null && urlResolver != null) {
                            value = urlResolver.ResolveClientUrl((string)value);
                        }
                    }

                    // add the value as an appropriate description
                    if(eventAttr != null) {
                        descriptor.AddEvent(propertyName, (string)value);
                    } else if(elementAttr != null) {
                        if(c == null && controlResolver != null)
                            c = controlResolver.ResolveControl((string)value);
                        if(c != null)
                            value = c.ClientID;
                        descriptor.AddElementProperty(propertyName, (string)value);
                    } else if(compAttr != null) {
                        if(c == null && controlResolver != null)
                            c = controlResolver.ResolveControl((string)value);
                        if(c != null) {
                            ExtenderControlBase ex = c as ExtenderControlBase;
                            if(ex != null && ex.BehaviorID.Length > 0)
                                value = ex.BehaviorID;
                            else
                                value = c.ClientID;
                        }
                        descriptor.AddComponentProperty(propertyName, (string)value);
                    } else {
                        if(c != null)
                            value = c.ClientID;
                        descriptor.AddProperty(propertyName, value);
                    }
                }
            }

            // determine if we should describe methods
            foreach(MethodInfo method in instance.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public)) {
                ExtenderControlMethodAttribute methAttr = (ExtenderControlMethodAttribute)Attribute.GetCustomAttribute(method, typeof(ExtenderControlMethodAttribute));
                if(methAttr == null || !methAttr.IsScriptMethod) {
                    continue;
                }

                // We only need to support emitting the callback target and registering the WebForms.js script if there is at least one valid method
                Control control = instance as Control;
                if(control != null) {
                    // Force WebForms.js
                    control.Page.ClientScript.GetCallbackEventReference(control, null, null, null);

                    // Add the callback target
                    descriptor.AddProperty("_callbackTarget", control.UniqueID);
                }
                break;
            }
        }
Пример #18
0
        public static void DescribeComponent(object instance, IScriptComponentDescriptor descriptor, IUrlResolutionService urlResolver, IControlResolver controlResolver)
        {
            // validate preconditions
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException("descriptor");
            }
            if (urlResolver == null)
            {
                urlResolver = instance as IUrlResolutionService;
            }
            if (controlResolver == null)
            {
                controlResolver = instance as IControlResolver;
            }

            // describe properties
            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(instance);

            foreach (PropertyDescriptor prop in properties)
            {
                ExtenderControlPropertyAttribute propAttr  = null;
                ExtenderControlEventAttribute    eventAttr = null;

                ClientPropertyNameAttribute  nameAttr    = null;
                IDReferencePropertyAttribute idRefAttr   = null;
                UrlPropertyAttribute         urlAttr     = null;
                ElementReferenceAttribute    elementAttr = null;
                ComponentReferenceAttribute  compAttr    = null;

                foreach (Attribute attr in prop.Attributes)
                {
                    Type attrType = attr.GetType();
                    if (attrType == typeof(ExtenderControlPropertyAttribute))
                    {
                        propAttr = attr as ExtenderControlPropertyAttribute;
                    }
                    else if (attrType == typeof(ExtenderControlEventAttribute))
                    {
                        eventAttr = attr as ExtenderControlEventAttribute;
                    }
                    else if (attrType == typeof(ClientPropertyNameAttribute))
                    {
                        nameAttr = attr as ClientPropertyNameAttribute;
                    }
                    else if (attrType == typeof(IDReferencePropertyAttribute))
                    {
                        idRefAttr = attr as IDReferencePropertyAttribute;
                    }
                    else if (attrType == typeof(UrlPropertyAttribute))
                    {
                        urlAttr = attr as UrlPropertyAttribute;
                    }
                    else if (attrType == typeof(ElementReferenceAttribute))
                    {
                        elementAttr = attr as ElementReferenceAttribute;
                    }
                    else if (attrType == typeof(ComponentReferenceAttribute))
                    {
                        compAttr = attr as ComponentReferenceAttribute;
                    }
                }

                string propertyName = prop.Name;

                // Try getting a property attribute
                if (propAttr == null || !propAttr.IsScriptProperty)
                {
                    // Try getting an event attribute
                    if (eventAttr == null || !eventAttr.IsScriptEvent)
                    {
                        continue;
                    }
                }

                // attempt to rename the property/event
                if (nameAttr != null && !string.IsNullOrEmpty(nameAttr.PropertyName))
                {
                    propertyName = nameAttr.PropertyName;
                }

                // determine whether to serialize the value of a property.  readOnly properties should always be serialized
                bool serialize = prop.ShouldSerializeValue(instance) || prop.IsReadOnly;
                if (serialize)
                {
                    // get the value of the property, skip if it is null
                    Control c     = null;
                    object  value = prop.GetValue(instance);
                    if (value == null)
                    {
                        continue;
                    }

                    // convert and resolve the value
                    if (eventAttr != null && prop.PropertyType != typeof(String))
                    {
                        throw new InvalidOperationException("ExtenderControlEventAttribute can only be applied to a property with a PropertyType of System.String.");
                    }
                    else
                    {
                        if (!prop.PropertyType.IsPrimitive && !prop.PropertyType.IsEnum)
                        {
                            // Check if we can use any of our custom converters
                            // (first do a direct lookup on the property type,
                            // but also check all of its base types if nothing
                            // was found)
                            Converter <object, string> customConverter = null;
                            if (!_customConverters.TryGetValue(prop.PropertyType, out customConverter))
                            {
                                foreach (KeyValuePair <Type, Converter <object, string> > pair in _customConverters)
                                {
                                    if (prop.PropertyType.IsSubclassOf(pair.Key))
                                    {
                                        customConverter = pair.Value;
                                        break;
                                    }
                                }
                            }

                            // Use the custom converter if found, otherwise use
                            // its current type converter
                            if (customConverter != null)
                            {
                                value = customConverter(value);
                            }
                            else
                            {
                                // Determine if we should let ASP.NET AJAX handle this type of conversion, as it supports JSON serialization
                                if (propAttr != null && propAttr.UseJsonSerialization)
                                {
                                    // Use ASP.NET JSON serialization
                                }
                                else
                                {
                                    // Use the property's own converter
                                    TypeConverter conv = prop.Converter;

                                    if (value.GetType() == typeof(DateTime))
                                    {
                                        value = ((DateTime)value).ToString("s", CultureInfo.InvariantCulture);
                                    }
                                    else
                                    {
                                        value = conv.ConvertToString(null, CultureInfo.InvariantCulture, value);
                                    }
                                }
                            }
                        }
                        if (idRefAttr != null && controlResolver != null)
                        {
                            c = controlResolver.ResolveControl((string)value);
                        }
                        if (urlAttr != null && urlResolver != null)
                        {
                            value = urlResolver.ResolveClientUrl((string)value);
                        }
                    }

                    // add the value as an appropriate description
                    if (eventAttr != null)
                    {
                        descriptor.AddEvent(propertyName, (string)value);
                    }
                    else if (elementAttr != null)
                    {
                        if (c == null && controlResolver != null)
                        {
                            c = controlResolver.ResolveControl((string)value);
                        }
                        if (c != null)
                        {
                            value = c.ClientID;
                        }
                        descriptor.AddElementProperty(propertyName, (string)value);
                    }
                    else if (compAttr != null)
                    {
                        if (c == null && controlResolver != null)
                        {
                            c = controlResolver.ResolveControl((string)value);
                        }
                        if (c != null)
                        {
                            ExtenderControlBase ex = c as ExtenderControlBase;
                            if (ex != null && ex.BehaviorID.Length > 0)
                            {
                                value = ex.BehaviorID;
                            }
                            else
                            {
                                value = c.ClientID;
                            }
                        }
                        descriptor.AddComponentProperty(propertyName, (string)value);
                    }
                    else
                    {
                        if (c != null)
                        {
                            value = c.ClientID;
                        }
                        descriptor.AddProperty(propertyName, value);
                    }
                }
            }

            // determine if we should describe methods
            foreach (MethodInfo method in instance.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public))
            {
                ExtenderControlMethodAttribute methAttr = (ExtenderControlMethodAttribute)Attribute.GetCustomAttribute(method, typeof(ExtenderControlMethodAttribute));
                if (methAttr == null || !methAttr.IsScriptMethod)
                {
                    continue;
                }

                // We only need to support emitting the callback target and registering the WebForms.js script if there is at least one valid method
                Control control = instance as Control;
                if (control != null)
                {
                    // Force WebForms.js
                    control.Page.ClientScript.GetCallbackEventReference(control, null, null, null);

                    // Add the callback target
                    descriptor.AddProperty("_callbackTarget", control.UniqueID);
                }
                break;
            }
        }
Пример #19
0
        public static void uploadControl_FileUploadComplete(object sender, FileUploadCompleteEventArgs e)
        {
            //string strFileNameBase = ImageContainerUpd.ImageBaseName.ToString();
            string strUpload         = ((DevExpress.Web.Mvc.MVCxUploadControl)sender).ClientID;
            string strFileNameBase   = ImageContainerUpd.ImageScanned.ToString();
            string strFileName       = e.UploadedFile.FileName;
            string strImageExtension = Path.GetExtension(e.UploadedFile.FileName);

            //ImageContainerUpd.ImageExtension = strImageExtension;

            switch (strUpload)
            {
            case "uploadControlKTP":
                //ImageContainerUpd.ImageFileKTP = strFileName;
                ImageContainerUpd.ImageExtensionKTP = strImageExtension;
                break;

            case "uploadControlNPWP":
                //ImageContainerUpd.ImageFileNPWP = strFileName;
                ImageContainerUpd.ImageExtensionNPWP = strImageExtension;
                break;

            case "uploadControlIAPI":
                //ImageContainerUpd.ImageFileIAPI = strFileName;
                ImageContainerUpd.ImageExtensionIAPI = strImageExtension;
                break;

            case "uploadControl1":
                //ImageContainerUpd.ImageFileName = strFileName; //untuk DocMandatoryDetail
                //ImageContainerUpd.ImageFile1 = strFileName;

                ImageContainerUpd.ImageExtension  = strImageExtension;    //untuk DocMandatoryDetail
                ImageContainerUpd.ImageExtension1 = strImageExtension;
                break;

            case "uploadControl2":
                //ImageContainerUpd.ImageFile2 = strFileName;
                ImageContainerUpd.ImageExtension2 = strImageExtension;
                break;

            case "uploadControl3":
                //ImageContainerUpd.ImageFile3 = strFileName;
                ImageContainerUpd.ImageExtension3 = strImageExtension;
                break;

            case "UCKeputusanMenKop":
                //ImageContainerUpd.ImageFileKOP = strFileName;
                ImageContainerUpd.ImageExtensionKOP = strImageExtension;
                break;

            case "UCSTTNPasarModal":
                //ImageContainerUpd.ImageFilePAS = strFileName;
                ImageContainerUpd.ImageExtensionPAS = strImageExtension;
                break;

            default:
                //ImageContainerUpd.ImageFileName = strFileName;
                ImageContainerUpd.ImageExtension = strImageExtension;
                break;
            }

            string resultFilePath = "~/Content/DocumentImages/" + string.Format("{0}{1}", strFileNameBase, strImageExtension);

            //e.UploadedFile.SaveAs(HttpContext.Current.Request.MapPath(resultFilePath));

            IUrlResolutionService urlResolver = sender as IUrlResolutionService;

            if (urlResolver != null)
            {
                e.CallbackData = urlResolver.ResolveClientUrl(resultFilePath) + "?refresh=" + Guid.NewGuid().ToString();
            }
        }
        private static Dictionary <string, object> BuildGraph(object obj, IUrlResolutionService uriResolver,
                                                              IControlResolver controlResolver)
        {
            Dictionary <string, object>  dict = new Dictionary <string, object>();
            PropertyDescriptorCollection pdc  = TypeDescriptor.GetProperties(obj);

            foreach (PropertyDescriptor pd in pdc)
            {
                ExtenderControlPropertyAttribute ecpa = GetAttribute <ExtenderControlPropertyAttribute>(pd);

                ClientPropertyNameAttribute    cpna = GetAttribute <ClientPropertyNameAttribute>(pd);
                IDReferencePropertyAttribute   idr  = GetAttribute <IDReferencePropertyAttribute>(pd);
                UrlPropertyAttribute           ura  = GetAttribute <UrlPropertyAttribute>(pd);
                ExtenderControlMethodAttribute ecma = GetAttribute <ExtenderControlMethodAttribute>(pd);
                ExtenderControlEventAttribute  ecea = GetAttribute <ExtenderControlEventAttribute>(pd);
                ElementReferenceAttribute      era  = GetAttribute <ElementReferenceAttribute>(pd);
                ComponentReferenceAttribute    cra  = GetAttribute <ComponentReferenceAttribute>(pd);
                if (ecpa == null && cra == null && cpna == null && era == null)
                {
                    continue;
                }


                string propName =
                    cpna != null && !string.IsNullOrEmpty(cpna.PropertyName)
                        ? cpna.PropertyName
                        : pd.Name;


                if (propName == "ClientClassName")
                {
                    propName = "typeToBuild";
                }

                object o     = null;
                object value = pd.GetValue(obj);
                if (value == null)
                {
                    continue;
                }

                if (value as IClientClass != null && ((IClientClass)value).NotSet)
                {
                    continue;
                }

                if (value as ClientEvalScript != null && string.IsNullOrEmpty((value as ClientEvalScript).ClientScript))
                {
                    continue;
                }

                if (pd.PropertyType == typeof(string))
                {
                    o = value;
                    if (ura != null)
                    {
                        o = uriResolver.ResolveClientUrl((string)o);
                    }
                    else if (idr != null || cra != null)
                    {
                        o = BuildGraph(new Reference
                        {
                            ReferenceType = ReferenceType.Component,
                            ClientId      = controlResolver.ResolveControl((string)o).ClientID
                        }, uriResolver, controlResolver);
                    }
                    else if (era != null)
                    {
                        Control c = controlResolver.ResolveControl((string)o);
                        o = BuildGraph(
                            new Reference
                        {
                            ReferenceType = ReferenceType.Element, ClientId = c == null ? (string)o : c.ClientID
                        },
                            uriResolver, controlResolver);
                    }
                }
                else if (value is IEnumerable)
                {
                    List <object> lst = new List <object>();
                    foreach (object a in (IEnumerable)value)
                    {
                        object b;
                        if (a as IUICollectionItem != null)
                        {
                            b = a is UriValue
                                    ? uriResolver.ResolveClientUrl(((UriValue)a).Value.ToString())
                                    : ((IUICollectionItem)a).Value;
                        }
                        else
                        {
                            b = BuildGraph(a, uriResolver, controlResolver);
                        }
                        if (b != null)
                        {
                            lst.Add(b);
                        }
                    }
                    if (lst.Count > 0)
                    {
                        o = lst;
                    }
                }
                else if (pd.PropertyType.IsEnum)
                {
                    o = Enum.GetName(pd.PropertyType, value);
                }
                else if (pd.PropertyType.IsPrimitive || pd.PropertyType.IsValueType)
                {
                    o = value;
                }
                else
                {
                    o = BuildGraph(value, uriResolver, controlResolver);
                }

                if (o != null)
                {
                    dict.Add(propName, o);
                }
            }
            return(dict.Count > 0 ? dict : null);
        }
Пример #21
0
        /// <summary>
        /// Fills the attributes collection given with the ones from the style
        /// </summary>
        /// <param name="attributes">The atrributes</param>
        /// <param name="urlResolver">The resolver to use</param>
        protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
        {
            base.FillStyleAttributes(attributes, urlResolver);

            if(!string.IsNullOrEmpty(BackgroundImageUrl))
                attributes.Add(HtmlTextWriterStyle.BackgroundImage, "url('" + urlResolver.ResolveClientUrl(BackgroundImageUrl) + "')");

            if(BackgroundImagePosition != BackgroundPosition.NotSet)
                attributes.Add("background-position", backgroundPos[(int)BackgroundImagePosition]);

            if(BackgroundImageRepeat != BackgroundRepeat.NotSet)
                attributes.Add("background-repeat", backgroundRpt[(int)BackgroundImageRepeat]);

            if(ZIndex != 0)
                attributes.Add(HtmlTextWriterStyle.ZIndex, ZIndex.ToString());

            if(Display != Display.NotSet)
                attributes.Add(HtmlTextWriterStyle.Display, displayStr[(int)Display]);

            if(Position != ElementPosition.NotSet)
                attributes.Add("position", positionStr[(int)Position]);

            if(!Left.IsEmpty)
                attributes.Add("left", Left.ToString());

            if(!Right.IsEmpty)
                attributes.Add("right", Right.ToString());

            if(!Top.IsEmpty)
                attributes.Add("top", Top.ToString());

            if(!Bottom.IsEmpty)
                attributes.Add("bottom", Bottom.ToString());

            if(Opacity != 1.0f)
            {
                attributes.Add("opacity", Opacity.ToString("0.0"));
                attributes.Add("-ms-filter", string.Format("progid:DXImageTransform.Microsoft.Alpha(Opacity={0:0})", Opacity * 100));
                attributes.Add("filter", string.Format("alpha(opacity={0:0})", Opacity * 100));
            }

            if(Float != ElementFloat.NotSet)
                attributes.Add("float", floatStr[(int)Float]);

            if(ListStyleType != ListStyleType.NotSet)
                attributes.Add(HtmlTextWriterStyle.ListStyleType, ListStyleTypeStr[(int)ListStyleType]);

            if(ListStylePosition != ListStylePosition.NotSet)
                attributes.Add("list-style-position", ListStylePositionStr[(int)ListStylePosition]);

            if(!string.IsNullOrEmpty(ListStyleImage))
                attributes.Add(HtmlTextWriterStyle.ListStyleImage, "url('" + urlResolver.ResolveClientUrl(ListStyleImage) + "')");
        }
Пример #22
0
		public static void DescribeComponent(object instance, ScriptComponentDescriptor descriptor, IUrlResolutionService urlResolver, IControlResolver controlResolver)
		{
			// validate preconditions
			if (instance == null) throw new ArgumentNullException("instance");
			if (descriptor == null) throw new ArgumentNullException("descriptor");
			if (urlResolver == null) urlResolver = instance as IUrlResolutionService;
			if (controlResolver == null) controlResolver = instance as IControlResolver;

			// describe properties
			// PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(instance);

			PropertyInfo[] properties = instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

			foreach (PropertyInfo prop in properties)
			{
				ScriptControlPropertyAttribute propAttr = null;
				ScriptControlEventAttribute eventAttr = null;
				string propertyName = prop.Name;

				System.ComponentModel.AttributeCollection attribs = new System.ComponentModel.AttributeCollection(Attribute.GetCustomAttributes(prop, false));

				// Try getting a property attribute
				propAttr = (ScriptControlPropertyAttribute)attribs[typeof(ScriptControlPropertyAttribute)];
				if (propAttr == null || !propAttr.IsScriptProperty)
				{
					// Try getting an event attribute
					eventAttr = (ScriptControlEventAttribute)attribs[typeof(ScriptControlEventAttribute)];
					if (eventAttr == null || !eventAttr.IsScriptEvent)
					{
						continue;
					}
				}

				// attempt to rename the property/event
				ClientPropertyNameAttribute nameAttr = (ClientPropertyNameAttribute)attribs[typeof(ClientPropertyNameAttribute)];
				if (nameAttr != null && !string.IsNullOrEmpty(nameAttr.PropertyName))
				{
					propertyName = nameAttr.PropertyName;
				}

				// determine whether to serialize the value of a property.  readOnly properties should always be serialized
				//bool serialize = true;// prop.ShouldSerializeValue(instance) || prop.IsReadOnly;
				//if (serialize)
				//{
				// get the value of the property, skip if it is null
				Control c = null;
				object value = prop.GetValue(instance, new object[0] { });
				if (value == null)
				{
					continue;
				}

				// convert and resolve the value
				if (eventAttr != null && prop.PropertyType != typeof(String))
				{
					throw new InvalidOperationException("ScriptControlEventAttribute can only be applied to a property with a PropertyType of System.String.");
				}
				else
				{
					if (!prop.PropertyType.IsPrimitive && !prop.PropertyType.IsEnum)
					{
						if (prop.PropertyType == typeof(Color))
						{
							value = ColorTranslator.ToHtml((Color)value);
						}
						else
						{
							// TODO: Determine if we should let ASP.NET AJAX handle this type of conversion, as it supports JSON serialization
							//TypeConverter conv = prop.Converter;
							//value = conv.ConvertToString(null, CultureInfo.InvariantCulture, value);

							//if (prop.PropertyType == typeof(CssStyleCollection))
							//    value = (new CssStyleCollectionJSCoverter()).Serialize(value, new JavaScriptSerializer());
							//if (prop.PropertyType == typeof(Style))
							//    value = (new CssStyleCollectionJSCoverter()).Serialize(((Style)value).GetStyleAttributes(null), new JavaScriptSerializer());                                

							Type valueType = value.GetType();

							JavaScriptConverterAttribute attr = (JavaScriptConverterAttribute)attribs[typeof(JavaScriptConverterAttribute)];
							JavaScriptConverter converter = attr != null ?
								(JavaScriptConverter)TypeCreator.CreateInstance(attr.ConverterType) :
								JSONSerializerFactory.GetJavaScriptConverter(valueType);

							if (converter != null)
								value = converter.Serialize(value, JSONSerializerFactory.GetJavaScriptSerializer());
							else
								value = JSONSerializerExecute.PreSerializeObject(value);

							//Dictionary<string, object> dict = value as Dictionary<string, object>;
							//if (dict != null && !dict.ContainsKey("__type"))
							//    dict["__type"] = valueType.AssemblyQualifiedName;
						}
					}
					if (attribs[typeof(IDReferencePropertyAttribute)] != null && controlResolver != null)
					{
						c = controlResolver.ResolveControl((string)value);
					}
					if (attribs[typeof(UrlPropertyAttribute)] != null && urlResolver != null)
					{
						value = urlResolver.ResolveClientUrl((string)value);
					}
				}

				// add the value as an appropriate description
				if (eventAttr != null)
				{
					if (!string.IsNullOrEmpty((string)value))
						descriptor.AddEvent(propertyName, (string)value);
				}
				else if (attribs[typeof(ElementReferenceAttribute)] != null)
				{
					if (c == null && controlResolver != null) c = controlResolver.ResolveControl((string)value);
					if (c != null) value = c.ClientID;
					descriptor.AddElementProperty(propertyName, (string)value);
				}
				else if (attribs[typeof(ComponentReferenceAttribute)] != null)
				{
					if (c == null && controlResolver != null) c = controlResolver.ResolveControl((string)value);
					if (c != null)
					{
						//ExtenderControlBase ex = c as ExtenderControlBase;
						//if (ex != null && ex.BehaviorID.Length > 0)
						//    value = ex.BehaviorID;
						//else
						value = c.ClientID;
					}
					descriptor.AddComponentProperty(propertyName, (string)value);
				}
				else
				{
					if (c != null) value = c.ClientID;
					descriptor.AddProperty(propertyName, value);
				}
			}
			//}

			// determine if we should describe methods
			foreach (MethodInfo method in instance.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public))
			{
				ScriptControlMethodAttribute methAttr = (ScriptControlMethodAttribute)Attribute.GetCustomAttribute(method, typeof(ScriptControlMethodAttribute));
				if (methAttr == null || !methAttr.IsScriptMethod)
				{
					continue;
				}

				// We only need to support emitting the callback target and registering the WebForms.js script if there is at least one valid method
				Control control = instance as Control;
				if (control != null)
				{
					// Force WebForms.js
					control.Page.ClientScript.GetCallbackEventReference(control, null, null, null);

					// Add the callback target
					descriptor.AddProperty("_callbackTarget", control.UniqueID);
				}
				break;
			}
		}
Пример #23
0
        public static void DescribeComponent(object instance, ScriptComponentDescriptor descriptor, IUrlResolutionService urlResolver, IControlResolver controlResolver)
        {
            // validate preconditions
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException("descriptor");
            }
            if (urlResolver == null)
            {
                urlResolver = instance as IUrlResolutionService;
            }
            if (controlResolver == null)
            {
                controlResolver = instance as IControlResolver;
            }

            // describe properties
            // PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(instance);

            PropertyInfo[] properties = instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            foreach (PropertyInfo prop in properties)
            {
                ScriptControlPropertyAttribute propAttr  = null;
                ScriptControlEventAttribute    eventAttr = null;
                string propertyName = prop.Name;

                System.ComponentModel.AttributeCollection attribs = new System.ComponentModel.AttributeCollection(Attribute.GetCustomAttributes(prop, false));

                // Try getting a property attribute
                propAttr = (ScriptControlPropertyAttribute)attribs[typeof(ScriptControlPropertyAttribute)];
                if (propAttr == null || !propAttr.IsScriptProperty)
                {
                    // Try getting an event attribute
                    eventAttr = (ScriptControlEventAttribute)attribs[typeof(ScriptControlEventAttribute)];
                    if (eventAttr == null || !eventAttr.IsScriptEvent)
                    {
                        continue;
                    }
                }

                // attempt to rename the property/event
                ClientPropertyNameAttribute nameAttr = (ClientPropertyNameAttribute)attribs[typeof(ClientPropertyNameAttribute)];
                if (nameAttr != null && !string.IsNullOrEmpty(nameAttr.PropertyName))
                {
                    propertyName = nameAttr.PropertyName;
                }

                // determine whether to serialize the value of a property.  readOnly properties should always be serialized
                //bool serialize = true;// prop.ShouldSerializeValue(instance) || prop.IsReadOnly;
                //if (serialize)
                //{
                // get the value of the property, skip if it is null
                Control c     = null;
                object  value = prop.GetValue(instance, new object[0] {
                });
                if (value == null)
                {
                    continue;
                }

                // convert and resolve the value
                if (eventAttr != null && prop.PropertyType != typeof(String))
                {
                    throw new InvalidOperationException("ScriptControlEventAttribute can only be applied to a property with a PropertyType of System.String.");
                }
                else
                {
                    if (!prop.PropertyType.IsPrimitive && !prop.PropertyType.IsEnum)
                    {
                        if (prop.PropertyType == typeof(Color))
                        {
                            value = ColorTranslator.ToHtml((Color)value);
                        }
                        else
                        {
                            // TODO: Determine if we should let ASP.NET AJAX handle this type of conversion, as it supports JSON serialization
                            //TypeConverter conv = prop.Converter;
                            //value = conv.ConvertToString(null, CultureInfo.InvariantCulture, value);

                            //if (prop.PropertyType == typeof(CssStyleCollection))
                            //    value = (new CssStyleCollectionJSCoverter()).Serialize(value, new JavaScriptSerializer());
                            //if (prop.PropertyType == typeof(Style))
                            //    value = (new CssStyleCollectionJSCoverter()).Serialize(((Style)value).GetStyleAttributes(null), new JavaScriptSerializer());

                            Type valueType = value.GetType();

                            JavaScriptConverterAttribute attr      = (JavaScriptConverterAttribute)attribs[typeof(JavaScriptConverterAttribute)];
                            JavaScriptConverter          converter = attr != null ?
                                                                     (JavaScriptConverter)TypeCreator.CreateInstance(attr.ConverterType) :
                                                                     JsonSerializerFactory.GetJavaScriptConverter(valueType);

                            if (converter != null)
                            {
                                value = converter.Serialize(value, JsonSerializerFactory.GetJavaScriptSerializer());
                            }
                            else
                            {
                                value = JsonHelper.PreSerializeObject(value);
                            }

                            //Dictionary<string, object> dict = value as Dictionary<string, object>;
                            //if (dict != null && !dict.ContainsKey("__type"))
                            //    dict["__type"] = valueType.AssemblyQualifiedName;
                        }
                    }
                    if (attribs[typeof(IDReferencePropertyAttribute)] != null && controlResolver != null)
                    {
                        c = controlResolver.ResolveControl((string)value);
                    }
                    if (attribs[typeof(UrlPropertyAttribute)] != null && urlResolver != null)
                    {
                        value = urlResolver.ResolveClientUrl((string)value);
                    }
                }

                // add the value as an appropriate description
                if (eventAttr != null)
                {
                    if (!string.IsNullOrEmpty((string)value))
                    {
                        descriptor.AddEvent(propertyName, (string)value);
                    }
                }
                else if (attribs[typeof(ElementReferenceAttribute)] != null)
                {
                    if (c == null && controlResolver != null)
                    {
                        c = controlResolver.ResolveControl((string)value);
                    }
                    if (c != null)
                    {
                        value = c.ClientID;
                    }
                    descriptor.AddElementProperty(propertyName, (string)value);
                }
                else if (attribs[typeof(ComponentReferenceAttribute)] != null)
                {
                    if (c == null && controlResolver != null)
                    {
                        c = controlResolver.ResolveControl((string)value);
                    }
                    if (c != null)
                    {
                        //ExtenderControlBase ex = c as ExtenderControlBase;
                        //if (ex != null && ex.BehaviorID.Length > 0)
                        //    value = ex.BehaviorID;
                        //else
                        value = c.ClientID;
                    }
                    descriptor.AddComponentProperty(propertyName, (string)value);
                }
                else
                {
                    if (c != null)
                    {
                        value = c.ClientID;
                    }
                    descriptor.AddProperty(propertyName, value);
                }
            }
            //}

            // determine if we should describe methods
            foreach (MethodInfo method in instance.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public))
            {
                ScriptControlMethodAttribute methAttr = (ScriptControlMethodAttribute)Attribute.GetCustomAttribute(method, typeof(ScriptControlMethodAttribute));
                if (methAttr == null || !methAttr.IsScriptMethod)
                {
                    continue;
                }

                // We only need to support emitting the callback target and registering the WebForms.js script if there is at least one valid method
                Control control = instance as Control;
                if (control != null)
                {
                    // Force WebForms.js
                    control.Page.ClientScript.GetCallbackEventReference(control, null, null, null);

                    // Add the callback target
                    descriptor.AddProperty("_callbackTarget", control.UniqueID);
                }
                break;
            }
        }
Пример #24
0
        /// <internalonly/>
        protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver) {
            base.FillStyleAttributes(attributes, urlResolver);

            string s = BackImageUrl;
            if (s.Length != 0) {
                if (urlResolver != null) {
                    s = urlResolver.ResolveClientUrl(s);
                }
                attributes.Add(HtmlTextWriterStyle.BackgroundImage, s);
            }
        }
Пример #25
0
		protected override void FillStyleAttributes (CssStyleCollection attributes, IUrlResolutionService urlResolver)
		{
			if (attributes != null) {
				string url = BackImageUrl;
				if (url.Length > 0) {
					if (urlResolver != null)
						url = urlResolver.ResolveClientUrl (url);
					attributes.Add (HtmlTextWriterStyle.BackgroundImage, url);
				}
			}
			base.FillStyleAttributes (attributes, urlResolver);
		}
		protected override void FillStyleAttributes (CssStyleCollection attributes, IUrlResolutionService urlResolver) {
			base.FillStyleAttributes (attributes, urlResolver);

			if (PaddingTop != Unit.Empty)
				attributes.Add (HtmlTextWriterStyle.PaddingTop, PaddingTop.ToString ());
			if (PaddingLeft != Unit.Empty)
				attributes.Add (HtmlTextWriterStyle.PaddingLeft, PaddingLeft.ToString ());
			if (PaddingRight != Unit.Empty)
				attributes.Add (HtmlTextWriterStyle.PaddingRight, PaddingRight.ToString ());
			if (PaddingBottom != Unit.Empty)
				attributes.Add (HtmlTextWriterStyle.PaddingBottom, PaddingBottom.ToString ());

			if (MarginTop != Unit.Empty)
				attributes.Add (HtmlTextWriterStyle.MarginTop, MarginTop.ToString ());
			if (MarginLeft != Unit.Empty)
				attributes.Add (HtmlTextWriterStyle.MarginLeft, MarginLeft.ToString ());
			if (MarginRight != Unit.Empty)
				attributes.Add (HtmlTextWriterStyle.MarginRight, MarginRight.ToString ());
			if (MarginBottom != Unit.Empty)
				attributes.Add (HtmlTextWriterStyle.MarginBottom, MarginBottom.ToString ());

            if(!String.IsNullOrEmpty(BackImageUrl))
            {
                attributes.Add(HtmlTextWriterStyle.BackgroundImage, String.Format("url({0})", urlResolver.ResolveClientUrl(BackImageUrl)));
            }
		}