public bool CanHaveStatefulFields(Control control) {
			if (control is LiteralControl) //quickly removed the LiteralControls
				return false;
			if (control is UserControl || control is Page)
			{
                if (control is IStatefulFieldsControl)
                    if( ((IStatefulFieldsControl) control).IgnoreStatefulFields) 
                        return false;
			    return Attribute.GetCustomAttribute(control.GetType(), typeof (IgnoreStatefulFields)) == null;
			}
			Type t = control.GetType();
			LogFactory.Log.Debug("inspecting " + t +  control.ID + "(" + control.UniqueID + ")");
			if (AllowedTypes.Contains(t))
				return true;
			if (FilteredTypes.Contains(t))
				return false;
			foreach (Type ft in FilteredBaseTypes)
				if (t.IsSubclassOf(ft)) {
					FilteredTypes.Add(t);
					return false;
				}
			//this line took too much resources:
			//return Attribute.GetCustomAttribute(control.GetType(), typeof (HasStatefulField)) != null;
			return true;
		}
        private static void ClearControls(Control control)
        {
            for (int index = control.Controls.Count - 1; index >= 0; index--)
            {
                ClearControls(control.Controls[index]);
            }

            if (!(control is TableCell))
            {
                if (control.GetType().GetProperty("SelectedItem") != null)
                {
                    LiteralControl m_Literal = new LiteralControl();
                    control.Parent.Controls.Add(m_Literal);

                    m_Literal.Text = (string)control.GetType().GetProperty("SelectedItem").GetValue(control, null);
                    control.Parent.Controls.Remove(control);
                }
                else
                {
                    if (control.GetType().GetProperty("Text") != null)
                    {
                        LiteralControl m_Literal = new LiteralControl();
                        control.Parent.Controls.Add(m_Literal);
                        m_Literal.Text = (string)control.GetType().GetProperty("Text").GetValue(control, null);
                        control.Parent.Controls.Remove(control);
                    }
                }
            }
        }
Esempio n. 3
0
        public static void ClearForm(Control container, FormClearOptions option, bool check_nc)
        {
            try
            {
                switch (option)
                {
                    case FormClearOptions.ClearAll:

                        if (check_nc)
                        {
                            if (container.ID != null)
                                if (container.ID.EndsWith("_nc"))
                                    break;
                        }

                        if (container.GetType().Equals(typeof(TextBox)))
                        {
                            TextBox txtBox = ((TextBox)container);
                            txtBox.Text = string.Empty;
                        }
                        else if (container.GetType().Equals(typeof(DropDownList)))
                        {
                            DropDownList ddl = ((DropDownList)container);
                            ddl.SelectedValue = string.Empty;
                        }
                        else if (container.GetType().Equals(typeof(CheckBox)))
                        {
                            CheckBox chk = ((CheckBox)container);
                            chk.Checked = false;
                        }
                        else if (container.GetType().Equals(typeof(RadioButtonList)))
                        {
                            RadioButtonList rbl = ((RadioButtonList)container);
                            rbl.SelectedIndex = -1;
                        }
                        else if (container.GetType().Equals(typeof(RadioButton)))
                        {
                            RadioButton rb = ((RadioButton)container);
                            rb.Checked = false;
                        }
                        else if (container.HasControls())
                        {
                            foreach (Control ctrl in container.Controls)
                                ClearForm(ctrl, option, check_nc);
                        }
                        break;

                    default:
                        break;
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
        public static void RegisterScriptInclude(Control control, string script) {
#if V2
#if DEBUG
            if (!control.Page.ClientScript.IsStartupScriptRegistered(script))
                control.Page.ClientScript.RegisterStartupScript(control.GetType(), control.GetType().FullName, GetAssemblyResource(script), true);
#else
            if (!control.Page.ClientScript.IsClientScriptIncludeRegistered(script))
                control.Page.ClientScript.RegisterClientScriptResource(control.GetType(), script);
#endif
#else
            if (!control.Page.IsStartupScriptRegistered(script))
                control.Page.RegisterClientScriptBlock(control.GetType().FullName, "<script language=\"javascript\" type=\"text/javascript\">\n" + GetAssemblyResource(script) + "\n</script>\n");
#endif
        }
Esempio n. 5
0
 /// <summary>
 /// Iterates through all the controls of the first control and 
 /// recursiv calling this funktion again until the control has no more sub Controls.
 /// If one control is a Button or a LinkButton, the eventscript will be added to the event
 /// </summary>
 /// <param name="ctrl">The Control to iterate through</param>
 /// <param name="eventString">the name of the event to assign</param>
 /// <param name="eventScript">The script to assign to the event</param>
 public static void AddEventToAllSubmitItems(Control ctrl, string eventString, string eventScript)
 {
     foreach (Control control in ctrl.Controls)
     {
         if (control != null)
         {
             AddEventToAllSubmitItems(control, eventString, eventScript);
         }
     }
     if (ctrl.GetType() == typeof(Button) || ctrl.GetType() == typeof(LinkButton) || ctrl.GetType() == typeof(ImageButton))
     {
         SetWebControlEvent((WebControl)ctrl, eventString, eventScript);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Aplica un ResourceText a los controles de la pagina que implementen la interfaz
 /// </summary>
 /// <param name="parentControl">Control parentControl, a partir de donde se van a buscar los controles</param>
 public void SetResourceText(System.Web.UI.Control parentControl)
 {
     foreach (System.Web.UI.Control control in parentControl.Controls)
     {
         this.SetResourceText(control);
     }
     if (parentControl.GetType() == typeof(Label))
     {
         (parentControl as Label).Text = this.GetResourceText(parentControl.ID);
     }
     if (parentControl.GetType() == typeof(Button))
     {
         (parentControl as Button).Text = this.GetResourceText(parentControl.ID);
     }
     if (parentControl.GetType() == typeof(ImageButton))
     {
         (parentControl as ImageButton).ToolTip = this.GetResourceText(parentControl.ID);
     }
     if (parentControl.GetType() == typeof(LinkButton))
     {
         (parentControl as LinkButton).Text = this.GetResourceText(parentControl.ID);
     }
     if (parentControl.GetType() == typeof(GridView))
     {
         foreach (GridViewRow row in (parentControl as GridView).Rows)
         {
             if (row.FindControl("confirm") != null)
             {
                 //  ((row.FindControl("confirm")) as AjaxControlToolkit.ConfirmButtonExtender).ConfirmText = "delete item?";
             }
         }
         foreach (DataControlField header in (parentControl as GridView).Columns)
         {
             if (header.GetType().Name.Equals("1 `", StringComparison.InvariantCultureIgnoreCase))
             {
                 if (!header.HeaderStyle.CssClass.Equals("hiddencol", StringComparison.InvariantCultureIgnoreCase))
                 {
                     string resource = "lbl" + ((header) as BoundField).DataField;
                     header.HeaderText = this.GetResourceText(resource).Replace(":", "");
                 }
             }
             if (header.GetType().Name.Equals("TemplateField", StringComparison.InvariantCultureIgnoreCase))
             {
                 string resource = "lbl" + ((header) as TemplateField).HeaderText;
                 header.HeaderText = this.GetResourceText(resource).Replace(":", "");
             }
         }
     }
 }
Esempio n. 7
0
    public void SetErrorOnField(bool bArgs, FormView objForm, string sFieldName)
    {
        // Dim TBcontrol As TextBox = objForm.FindControl(sFieldName)
        System.Web.UI.Control GenericControl = objForm.FindControl(sFieldName);

        if (bArgs != true)
        {
            switch ((GenericControl.GetType().ToString()))
            {
            case "System.Web.UI.WebControls.TextBox":
            {
                TextBox TB = (TextBox)GenericControl;
                TB.Style["background-Color"] = "#FFFFD5";
                TB.Style["border-Color"]     = "#FF5353";
                break;
            }

            case "System.Web.UI.WebControls.DropDownList":
            {
                DropDownList DDL = (DropDownList)GenericControl;
                DDL.Style["background-Color"] = "#FFFFD5";
                DDL.Style["border-Color"]     = "#FF5353";
                break;
            }
            }
        }
        else
        {
            switch ((GenericControl.GetType().ToString()))
            {
            case "System.Web.UI.WebControls.TextBox":
            {
                TextBox TB = (TextBox)GenericControl;
                TB.Style["background-Color"] = "#FFF";
                TB.Style["border-Color"]     = "#C7C7C7";
                break;
            }

            case "System.Web.UI.WebControls.DropDownList":
            {
                DropDownList DDL = (DropDownList)GenericControl;
                DDL.Style["background-Color"] = "#FFF";
                DDL.Style["border-Color"]     = "#C7C7C7";
                break;
            }
            }
        }
    }
Esempio n. 8
0
        public void InjectInto(Control control)
        {
            if (_cfg.TypeResolver == null)
            {
                throw new InvalidOperationException("Please configure your container bindings.");
            }

            var injectTheseProperties = _injectionMap.Lookup(control.GetType());
            foreach (var property in injectTheseProperties)
            {
                var instance = _cfg.TypeResolver.Resolve(property.Type);

                if (instance == null)
                {
                    System.Diagnostics.Debug.WriteLine("Attempt to inject value into member " + property.UnderlyingValue.Name + " resulted in a NULL.");
                }

                property.SetValue(control, instance);
            }

            foreach (var child in GetControlTree(control))
            {
                InjectInto(child);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Adds the CSS class.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="classNameToAdd">The class name to add.</param>
        public static void AddCssClass(Control control, string classNameToAdd)
        {
            string cssClasses;
            if (control is HtmlControl)
            {
                cssClasses = ((HtmlControl)control).Attributes[Constants.HtmlAttributes.Class];
            }
            else if (control is WebControl)
            {
                cssClasses = ((WebControl)control).CssClass;
            }
            else
            {
                throw new NotSupportedException("Type '" + control.GetType() + "' is not supported!");
            }

            if (String.IsNullOrEmpty(cssClasses))
            {
                cssClasses = String.Empty;
            }

            cssClasses += " " + classNameToAdd;
            if (control is HtmlControl)
            {
                ((HtmlControl)control).Attributes[Constants.HtmlAttributes.Class] = cssClasses;
            }
            else if (control is WebControl)
            {
                ((WebControl)control).CssClass = cssClasses;
            }
        }
Esempio n. 10
0
        public static void ShowMessageBox(Control p, string Message, string BoxTitle, MessageBoxType type)
        {
            Message = Message.Replace("\r\n", "");
            Message = Message.Replace("<BR>", "{BR}");
            Message = Message.Replace("<", "{START}");
            Message = Message.Replace(">", "{END}");
            Message = Message.Replace("\"", "{Q}");


            string ImagePath = string.Format(p.ResolveUrl("~/App_Themes/MessageBox/{0}.png"), type.GetEnumName());

            string script = string.Format(@"<script type=""text/javascript"">
                                 ShowJQMessageBox(' <fieldset style=""direction:rtl;width:400px;max-width:600px;min-width: 300px;"" align=""center""><legend><img  align=""middle"" src=""{0}"" Width=""32"" />{1} </legend>  <span style=""direction:rtl;text-align:right"">{2}</span></fieldset>');
                               </script>", ImagePath, BoxTitle, HttpContext.Current.Server.HtmlEncode(Message));



            script = script.Replace("{BR}", "<BR>");
            script = script.Replace("{START}", "<");
            script = script.Replace("{END}", ">");
            script = script.Replace("{Q}", "\"");

            ScriptManager.RegisterClientScriptBlock(p, p.GetType(), "message", script, false);

        }
Esempio n. 11
0
 /// <summary>
 /// 为不同的控件赋值
 /// </summary>
 /// <param name="ctl">控件</param>
 /// <param name="oValue">值</param>
 public void aInitSetValue(Control ctl, object oValue)
 {
     string thisValue = string.Empty;
     if (oValue != null)
     {
         thisValue = oValue.ToString();
     }
     else
     {
         thisValue = "null";
     }
     switch (ctl.GetType().ToString())
     {
         case "System.Web.UI.WebControls.Literal":
             Literal lit = (Literal)ctl;
             lit.Text = thisValue;
             break;
         case "System.Web.UI.WebControls.TextBox":
             TextBox txt = (TextBox)ctl;
             txt.Text = thisValue;
             break;
         case "System.Web.UI.WebControls.RadioButtonList":
             RadioButtonList rbl = (RadioButtonList)ctl;
             rbl.SelectedValue = thisValue;
             break;
         case "System.Web.UI.WebControls.DropDownList":
             break;
     }
 }
Esempio n. 12
0
 /// <summary>
 /// 弹出消息框并且转向到新的URL
 /// </summary>
 /// <param name="control">注册控件</param>
 /// <param name="message">消息内容</param>
 /// <param name="toURL">连接地址</param>
 public static void AlertAndRedirect(System.Web.UI.Control source, string message, string toURL)
 {
     #region
     string js = "alert('{0}');window.location.replace('{1}')";
     ScriptManager.RegisterClientScriptBlock(source, source.GetType(), "msg", string.Format(js, message, toURL), true);
     #endregion
 }
        private static void InvokeConstructor(IServiceProvider container, Control instance) {
            var type = instance.GetType();

            var constructor = GetConstructor(type);
            while (constructor == null && type != typeof (Page) && type != typeof (MasterPage) &&
                   type != typeof (UserControl) && type != null) {
                type = type.BaseType;
                constructor = GetConstructor(type);
            }

            if (constructor == null) {
                // only Default constructor
                return;
            }

            try {
                var args =
                    constructor.GetParameters().Select(x => container.GetRequiredService(x.ParameterType)).ToArray();
                constructor.Invoke(instance, args);
            }
            catch (Exception ex) {
                var message = Resources.Error_PageInitializationFail_Message(type.FullName, ex.Message);
                throw new InvalidOperationException(message, ex);
            }
        }
Esempio n. 14
0
 private Control CloneControl(System.Web.UI.Control src_ctl)
 {
     Type t = src_ctl.GetType();
     Object obj = Activator.CreateInstance(t);
     Control dst_ctl = (Control)obj;
     PropertyDescriptorCollection src_pdc = TypeDescriptor.GetProperties(src_ctl);
     PropertyDescriptorCollection dst_pdc = TypeDescriptor.GetProperties(dst_ctl);
     for (int i = 0; i < src_pdc.Count; i++)
     {
         if (src_pdc[i].Attributes.Contains(DesignerSerializationVisibilityAttribute.Content))
         {
             object collection_val = src_pdc[i].GetValue(src_ctl);
             if ((collection_val is IList) == true)
             {
                 foreach (object child in (IList)collection_val)
                 {
                     Control new_child = CloneControl(child as Control);
                     object dst_collection_val = dst_pdc[i].GetValue(dst_ctl);
                     ((IList)dst_collection_val).Add(new_child);
                 }
             }
         }
         else
         {
             dst_pdc[src_pdc[i].Name].SetValue(dst_ctl, src_pdc[i].GetValue(src_ctl));
         }
     }
     return dst_ctl;
 }
Esempio n. 15
0
        public void DataBind(string viewName)
        {
            string      _pageName = WComm.Utilities.getCurPage;
            List <View> _viewList = View.getViewList(_pageName);
            View        _view     = View.getViewByName(viewName, _viewList);

            if (_view == null)
            {
                throw new Exception("Can't find Usercontrol " + viewName + " in View.config");
            }

            System.Web.UI.Control _control = null;
            _control = FindControl(_view.Type, this.Page);
            if (_control == null)
            {
                throw new Exception("Can't find Usercontrol " + _view.Name + " in Page");
            }

            MethodInfo mi = _control.GetType().GetMethod("DataBind");

            if (mi != null)
            {
                mi.Invoke(_control, null);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// �رմ���
        /// </summary>
        /// <param name="p"></param>
        /// <param name="msg"></param>
        public static void Close(Control c)
        {
            ValidPage(c);

            c.Page.ClientScript.RegisterStartupScript( c.GetType(), "__Close",
                WrapJs( "window.close();" ));
        }
 public override void DataBindControl(IDesignerHost designerHost, Control control)
 {
     DataBinding runtimeDataBinding = ((IDataBindingsAccessor) control).DataBindings["Text"];
     if (runtimeDataBinding != null)
     {
         PropertyInfo property = control.GetType().GetProperty("Text");
         if ((property != null) && (property.PropertyType == typeof(string)))
         {
             DesignTimeDataBinding binding2 = new DesignTimeDataBinding(runtimeDataBinding);
             string str = string.Empty;
             if (!binding2.IsCustom)
             {
                 try
                 {
                     str = DataBinder.Eval(((IDataItemContainer) control.NamingContainer).DataItem, binding2.Field, binding2.Format);
                 }
                 catch
                 {
                 }
             }
             if ((str == null) || (str.Length == 0))
             {
                 str = System.Design.SR.GetString("Sample_Databound_Text");
             }
             property.SetValue(control, str, null);
         }
     }
 }
Esempio n. 18
0
        /// <summary>
        /// ǰ��
        /// </summary>
        /// <param name="c"></param>
        public static void Forward(Control c)
        {
            ValidPage(c);

            c.Page.ClientScript.RegisterStartupScript(c.GetType(), "__Forward",
                WrapJs("history.go(1);"));
        }
Esempio n. 19
0
        public static void ExcedJS(Control c, string msg)
        {
            ValidPage(c);

            c.Page.ClientScript.RegisterStartupScript(c.GetType(), "__Exced",
                WrapJs(msg));
        }
Esempio n. 20
0
 public EzJavaScriptManager(Control control)
 {
     _page = control.Page;
     _control = control;
     _type = control.GetType();
     _isInUpdatePanel = _control.IsInUpdatePanel();
 }
Esempio n. 21
0
 public static void SetWhenIsNotNull(this System.Web.UI.Control control, string value)
 {
     if (control != null)
     {
         if (control is System.Web.UI.ITextControl)
         {
             System.Web.UI.ITextControl textControl = (System.Web.UI.ITextControl)control;
             textControl.Text = value;
         }
         else if (control is System.Web.UI.HtmlControls.HtmlInputControl)
         {
             System.Web.UI.HtmlControls.HtmlInputControl htmlInputControl = (System.Web.UI.HtmlControls.HtmlInputControl)control;
             htmlInputControl.Value = value;
         }
         else
         {
             if (!(control is System.Web.UI.WebControls.HyperLink))
             {
                 throw new System.ApplicationException("未实现" + control.GetType().ToString() + "的SetWhenIsNotNull方法");
             }
             System.Web.UI.WebControls.HyperLink hyperLink = (System.Web.UI.WebControls.HyperLink)control;
             hyperLink.NavigateUrl = value;
         }
     }
 }
Esempio n. 22
0
        /// <summary>
        /// �ڿͻ�����ʾһ����Ϣ
        /// </summary>
        /// <param name="c"></param>
        /// <param name="msg"></param>
        public static void Alert( Control c , string msg )
        {
            ValidPage(c);

            c.Page.ClientScript.RegisterStartupScript( c.GetType(), "__Alert",
                WrapJs( string.Format( "alert(\"{0}\");" , JsEncoder.Encode( msg ) ) ) ) ;
        }
Esempio n. 23
0
        /// <summary>
        /// ����
        /// </summary>
        /// <param name="c"></param>
        public static void Back(Control c)
        {
            ValidPage(c);

            c.Page.ClientScript.RegisterStartupScript(c.GetType(), "__Back",
                WrapJs("history.back();"));
        }
 private static void RegisterEmbeddedResource(Type type, Control control, string projectQualifiedResourceName, string scriptFormat)
 {
     if (control.Page.ClientScript.IsClientScriptIncludeRegistered(projectQualifiedResourceName))
         return;
     var resourceUrl = control.Page.ClientScript.GetWebResourceUrl(type, projectQualifiedResourceName);
     var includeTag = string.Format(scriptFormat, resourceUrl);
     control.Page.ClientScript.RegisterClientScriptBlock(control.GetType(), projectQualifiedResourceName, includeTag, false);
 }
 public static void ShowPopup(string id, Control control, bool addScript = false)
 {
     var sb = new System.Text.StringBuilder();
     sb.Append(@"<script type='text/javascript'>");
     sb.Append("$('"+id+"').modal('show');");
     sb.Append(@"</script>");
     ScriptManager.RegisterClientScriptBlock(control, control.GetType(), "ModalScript", sb.ToString(), addScript);
 }
Esempio n. 26
0
        public void RegisterClientScript(Control control, string functionName, string param)
        {
            // initialize the function call as a string script
            string script = string.Format("{0}('{1}')", functionName, param);

            // register the startup script event to call the function
            ScriptManager.RegisterStartupScript(control, control.GetType(), Guid.NewGuid().ToString(), script, true);
        }
Esempio n. 27
0
        public static void Show(string message, Control owner)
        {
            Page page = (owner as Page) ?? owner.Page;
            if (page == null) return;

            page.ClientScript.RegisterStartupScript(owner.GetType(),
                "ShowMessage", string.Format("<script type='text/javascript'>alert('{0}')</script>",
                message));
        }
Esempio n. 28
0
        public ControlLocalizer (Control control)
        {
            // use control base type name, not .ascx one!
            LocalResourceFile = Localization.GetResourceFile (control, control.GetType ().BaseType.Name + ".ascx");

            // skinobjects must use resourses from skin directory
            if (control is SkinObjectBase)
                LocalResourceFile = LocalResourceFile.Replace ("/Controls", string.Empty);
        }
Esempio n. 29
0
			public override void AddAt(int index, Control child)
			{
				if (!(child is TableRow))
					throw new ArgumentException (HttpRuntime.FormatResourceString (
									"Cannot_Have_Children_Of_Type",
									"Table",
									child.GetType ().Name.ToString ()));
				base.AddAt (index, child);
			}
        static bool IncludeControl(Control serverControl)
        {
            var returnedVal = false;
            var controlType = serverControl.GetType().ToString();
            if(controlType.IndexOf("Sys.Extended.UI.maskededitextender", StringComparison.OrdinalIgnoreCase) != -1)
                returnedVal = true;

            return returnedVal;
        }
        /// <summary>
        /// Método encargado de Alternar las ventanas Modales
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="comando"></param>
        private void alternarVentana(System.Web.UI.Control sender, string comando)
        {
            //Validando Comando
            switch (comando)
            {
            case "ResultadoSAT":
                ScriptServer.AlternarVentana(sender, sender.GetType(), comando, "contenidoResultadoConsultaSATModal", "contenidoResultadoConsultaSAT");
                break;

            case "ImportacionCxP":
                ScriptServer.AlternarVentana(sender, sender.GetType(), comando, "contenedorVentanaImportacionCxP", "ventanaImportacionCxP");
                break;

            case "LigaEgresos":
                ScriptServer.AlternarVentana(sender, sender.GetType(), comando, "contenedorVentanaLigaEgresos", "ventanaLigaEgresos");
                break;
            }
        }
Esempio n. 32
0
 public void Execute(Page page, Control source, object argument)
 {
     var target = source.NamingContainer.FindControl((string)argument) as Label;
     if (target == null)
     {
         return;
     }
     target.Text = "I was updated by the UpdateLabelCommand via a " + source.GetType().Name;
 }
Esempio n. 33
0
		/// <summary>
		/// Verifica se um controle está vazio.
		/// </summary>
		/// <param name="ctl">O controle</param>
		/// <returns>Verdadeiro se o controle está vazio, falso caso contrário</returns>
		/// <remarks>
		/// Um controle pode estar vazio pelos motivos abaixo:
		/// <list type="bullet">
		///		<item>Seu valor em <see cref="String"/> é igual a nulo ou a <see cref="String.Empty"/></item>
		///		<item>É um <see cref="ListControl"/> e não tem nenhum item selecionado</item>
		/// </list>
		/// </remarks>
		public static bool IsEmpty(Control ctl)
		{
			object val = GetValue(ctl);
			if (val == null) return true;
			if (val is Array) return ((Array) val).Length == 0;
			if (val is string) return ((string) val).Length == 0;

			throw new Exception("Control Type not supported: " + ctl.GetType().FullName);
		}
 private static bool IncludeControl(Control serverControl)
 {
     bool ReturnedVal = false;
     string ControlType = serverControl.GetType().ToString();
     if (ControlType.IndexOf("Sys.Extended.UI.maskededitextender", StringComparison.OrdinalIgnoreCase) != -1)
     {
         ReturnedVal = true;
     }
     return ReturnedVal;
 }
 private string[] GetPropertyNames(Control control)
 {
     ArrayList list = new ArrayList();
     foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(control.GetType()))
     {
         list.Add(descriptor.Name);
     }
     list.Sort(Comparer.Default);
     return (string[]) list.ToArray(typeof(string));
 }
Esempio n. 36
0
        /// <summary>
        /// Initializes the <see cref="T:System.Web.UI.WebControls.BoundField" /> object.
        /// </summary>
        /// <param name="enableSorting">true if sorting is supported; otherwise, false.</param>
        /// <param name="control">The data control that owns the <see cref="T:System.Web.UI.WebControls.BoundField" />.</param>
        /// <returns>
        /// false in all cases.
        /// </returns>
        public override bool Initialize( bool enableSorting, Control control )
        {
            string script = @"
            $('.grid-table tr td span.date-field').tooltip({html: true, container: 'body', delay: { show: 100, hide: 100 }});
            $('.grid-table tr td span.date-field').click( function(){ $(this).tooltip('hide'); });;
            ";
            ScriptManager.RegisterStartupScript( control, control.GetType(), "date-field-popover", script, true );

            return base.Initialize( enableSorting, control );
        }
Esempio n. 37
0
 internal AjaxBase(System.Web.UI.Control control, HttpContext context)
 {
     if (!(control is IAjaxControl))
     {
         throw new System.InvalidOperationException();
     }
     _control    = control;
     _properties = WebBindable.Properties(_control.GetType());
     _context    = context;
     _bindings   = new PropertyBindings((IAjaxControl)_control);
 }
Esempio n. 38
0
 private static bool ContainsRecursive(Type controlType, Control container)
 {
     if(container.GetType() == controlType)
         return true;
     foreach (Control c in container.Controls)
     {
         if (ContainsRecursive(controlType, c))
             return true;
     }
     return false;
 }
Esempio n. 39
0
    public static void TranslateProperty(string propertyName, System.Web.UI.Control c)
    {
        string controlValue;

        try
        {
            if (c.GetType().GetProperty(propertyName) != null)
            {
                controlValue = c.GetType().GetProperty(propertyName).GetValue(c, null).ToString();
                if (controlValue != string.Empty)
                {
                    if (ConfigurationManager.AppSettings["DebugTranslationShowType"].ToString() == "yes")
                    {
                        controlValue = controlValue + " - " + c.GetType().ToString();
                    }
                    c.GetType().GetProperty(propertyName).SetValue(c, GetTranslation(controlValue), null);
                }
            }
        }
        catch { }
    }
Esempio n. 40
0
 /// <summary>
 /// Ensures that the server form, which this control belongs to, has an enctype of "multipart/form-data".
 /// </summary>
 protected virtual void EnsureEncType()
 {
     System.Web.UI.Control parent = this.Parent;
     while (parent != null && parent.GetType() != typeof(System.Web.UI.HtmlControls.HtmlForm) && parent.GetType() != typeof(System.Web.UI.Page))
     {
         parent = parent.Parent;
     }
     System.Web.UI.HtmlControls.HtmlForm myForm = parent as System.Web.UI.HtmlControls.HtmlForm;
     if (myForm != null)
     {
         myForm.Enctype = "multipart/form-data";
     }
 }
Esempio n. 41
0
        public static void FindControlRecursive(System.Web.UI.Control Root)
        {
            if (Root.GetType() == typeof(TextBox))
            {
                TextBox txt = ((TextBox)Root);
                RemoverCaracteresTexto(txt);
            }

            foreach (System.Web.UI.Control Ctl in Root.Controls)
            {
                FindControlRecursive(Ctl);
            }
        }
Esempio n. 42
0
 /// <summary>
 /// 弹出一个提示框
 /// </summary>
 /// <param name="message"></param>
 public static void SetAlert(System.Web.UI.Control control, string message)
 {
     try
     {
         Literal lit = (Literal)control;
         lit.Text = "<script>alert(\"" + message + "\");</script>";
     }
     catch
     {
         ScriptManager.RegisterClientScriptBlock(control, control.GetType(), "aaa", "<script>alert(\"" + message + "\");</script>", false);
     }
     //HttpContext.Current.Response.Write("<script>alert(\""+message+"\");</script>");
 }
Esempio n. 43
0
        /// <summary>
        /// Convert from one type to another.
        /// </summary>
        /// <param name="control">The web control instance.</param>
        /// <param name="type">The system type to convert to.</param>
        /// <returns>The new type containing the data.</returns>
        public static object WebControlConvertType(
            System.Web.UI.Control control, Type type)
        {
            switch (control.GetType().FullName.ToLower())
            {
            case "system.web.ui.webcontrols.checkbox":
                CheckBox checkBox = (CheckBox)control;
                return(Nequeo.DataType.ConvertType(checkBox.Checked, type));

            default:
                TextBox textBox = (TextBox)control;
                return(Nequeo.DataType.ConvertType(textBox.Text, type));
            }
        }
Esempio n. 44
0
        /// <summary>
        /// Adds Javascript code to safely set focus on the specified control.
        /// </summary>
        public static void Focus(this Web.UI.Control control, bool safe)
        {
            if (!safe)
            {
                control.Focus();
            }

            var script =
                @"setTimeout(function() {                     
                    var fn = function() { 
                        var control = $get('#CLIENT_ID#'); 
                        if (control && control.focus) { try { control.focus(); } catch (err) { } }
                        try{ Sys.Application.remove_load(fn); } catch (err) { }
                    };
                    Sys.Application.add_load(fn); fn();
                }, 10);".Replace("#CLIENT_ID#", control.ClientID);

            ScriptManager.RegisterStartupScript(control.Page, control.GetType(), control.ClientID + "_SetFocusOnLoad", script, addScriptTags: true);
        }
Esempio n. 45
0
    public static void AjaxAlert(System.Web.UI.Control reg_control, string message)
    {
        if (message == null)
        {
            message = string.Empty;
        }
        message = message.Replace("'", "''");

        ScriptManager.RegisterStartupScript(reg_control,
                                            reg_control.GetType(),
                                            Guid.NewGuid().ToString(),
                                            string.Format("alert('{0}');", message),
                                            true);

        ////ScriptManager.RegisterClientScriptBlock(reg_control,
        ////                                       reg_control.GetType(),
        ////                                       Guid.NewGuid().ToString(),
        ////                                       string.Format("alert('{0}');", message),
        ////                                       true);
    }
Esempio n. 46
0
            // Displays a textbox form to receive an HTML
            // string that represents a control, and creates
            // a toolbox item for the control, if not already
            // present in the selected toolbox category.
            private void loadPersistedControl()
            {
                // Display a StringInputForm to obtain a persisted control string.
                StringInputForm inputForm = new StringInputForm();

                if (inputForm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                if (inputForm.TBox.Text.Length < 2)
                {
                    return;
                }

                // Obtain an IDesignerHost for the design-mode document.
                IDesignerHost host = (IDesignerHost)
                                     this.Component.Site.GetService(typeof(IDesignerHost));

                //<Snippet2>
                // Create a Web control from the HTML markup.
                System.Web.UI.Control ctrl =
                    ControlParser.ParseControl(host, inputForm.TBox.Text.Trim());
                //</Snippet2>

                // Create a Web control toolbox item for the type of the control
                System.Web.UI.Design.WebControlToolboxItem item =
                    new System.Web.UI.Design.WebControlToolboxItem(ctrl.GetType());

                // Add the Web control toolbox item to the toolbox
                IToolboxService toolService = (IToolboxService)
                                              this.Component.Site.GetService(typeof(IToolboxService));

                if (toolService != null)
                {
                    toolService.AddToolboxItem(item);
                }
                else
                {
                    throw new Exception("IToolboxService was not found.");
                }
            }
Esempio n. 47
0
        public static void FillExtension(WebUI.Control control, Dictionary <string, object> extensions)
        {
            foreach (var pi in extensions.Keys)
            {
                WebUI.Control ctl = control.FindControl(string.Format(IdFormat, pi));
                if (ctl == null)
                {
                    continue;
                }
                Type ctlType = ctl.GetType();



                if (ctlType == typeof(WebUI.WebControls.TextBox))  //文本框
                {
                    if (extensions[pi] != null)
                    {
                        ((WebUI.WebControls.TextBox)ctl).Text = GetFormatStr(extensions[pi]);
                    }
                }
            }
        }
Esempio n. 48
0
 /// <summary>
 /// 取得ASCX在伺服器上的路徑
 /// </summary>
 public static string GetAscxPath(System.Web.UI.Control control)
 {
     if (IsDebug())
     {
         //return string.Format("\\{0}\\{1}.ascx<hr class='style-one'/>", dir, control.GetType().ToString().Replace("ASP.", ""))
         //	.Replace(HttpContext.Current.Server.MapPath("/"), "");
         if ((control.TemplateControl.ID ?? "") != "")
         {
             return(string.Format("<hr class='style-one'/>{0}/{1}.ascx<BR>", control.TemplateSourceDirectory, control.TemplateControl.ID));
         }
         else
         {
             return(string.Format("<hr class='style-one'/>{0}/{1}.ascx<BR>", control.TemplateSourceDirectory, control.GetType().ToString().Replace("ASP.", "")));
         }
     }
     else
     {
         return("");
     }
 }
Esempio n. 49
0
    public static void MuestraMensaje(string mensaje, string funcion, System.Web.UI.Control control)
    {
        string strScript = "<script type='text/javascript'>" + funcion + "('" + mensaje + "');</script>";

        System.Web.UI.ScriptManager.RegisterStartupScript(control, control.GetType(), "msgbox", strScript, false);
    }//void
Esempio n. 50
0
    public void BuildCriteria(System.Web.UI.Control MyWebServerControl, string sItemName, string sItemValue, string sItemType, ref string sCriterioItemForma)
    {
        //  esta funci�n recibe una expresi�n para un item determinado y regresa el
        //  criterio apropiado para usarlo en la parte "where" de una instrucci�n Sql.
        //  Por ejemplo: se recibe 4 para el item Empleado (de tipo Numerico) y se
        //  regresa: (Empleado = 4)
        switch (MyWebServerControl.GetType().Name.ToString())
        {
        case "TextBox":
            sItemValue = sItemValue.Replace(">", " > ");
            sItemValue = sItemValue.Replace("<", " < ");
            sItemValue = sItemValue.Trim();
            //  ------------------------------------------------------------
            //  el usuario puede indicar 'is null / is not null'
            if ((string.Compare(sItemValue.Trim(), "is null", true) == 0))
            {
                sCriterioItemForma = ("("
                                      + (sItemName + " Is Null)"));
                return;
            }
            else if ((string.Compare(sItemValue.Trim(), "is not null", true) == 0))
            {
                sCriterioItemForma = ("("
                                      + (sItemName + " Is Not Null)"));
                return;
            }
            //  ------------------------------------------------------------
            if ((sItemType == "Date"))
            {
                sItemValue = sConvertirFechasAFormaYMD(sItemValue);
            }
            if ((sItemType == "Date"))
            {
                sItemValue = sEncerrarPalabrasEntreComillasSimples(sItemValue);
            }
            if ((sItemType == "String"))
            {
                sItemValue = sSepararPalabrasEnListaOr(sItemValue, sItemName);
            }
            switch (sItemType)
            {
            case "Date":
                if ((((sItemValue.IndexOf("entre") + 1)
                      > 0) ||
                     (((sItemValue.IndexOf("Entre") + 1)
                       > 0) ||
                      ((sItemValue.IndexOf("ENTRE") + 1)
                       > 0))))
                {
                    if (!linqToEntities)
                    {
                        //  el usuario uso un criterio: 'entre xxx y zzz'
                        sItemValue = sItemValue.Replace("\'entre\'", "between");
                        sItemValue = sItemValue.Replace("\'Entre\'", "between");
                        sItemValue = sItemValue.Replace("\'ENTRE\'", "between");
                        sItemValue = sItemValue.Replace("\'y\'", "and");
                        sItemValue = sItemValue.Replace("\'Y\'", "and");

                        sCriterioItemForma = ("("
                                              + (sItemName + (" "
                                                              + (sItemValue + ")"))));
                    }
                    else
                    {
                        DateTime fechaInicio;
                        DateTime fechaFinal;

                        string[] words = sItemValue.Replace("'", "").Split(' ');

                        if (!DateTime.TryParse(words[1], out fechaInicio))
                        {
                            // cómo terminar con error ???
                        }

                        if (!DateTime.TryParse(words[3], out fechaFinal))
                        {
                            // cómo terminar con error ???
                        }

                        sCriterioItemForma += "(" + sItemName + " >= DateTime'" + fechaInicio.ToString("yyyy-MM-dd H:m:s") +
                                              "' And " + sItemName + " <= DateTime'" + fechaFinal.ToString("yyyy-MM-dd") + " 23:59:59')";
                    }
                }
                else if ((((sItemValue.IndexOf(" \'o\' ") + 1)
                           > 0) ||
                          ((sItemValue.IndexOf(" \'O\' ") + 1)
                           > 0)))
                {
                    if (!linqToEntities)
                    {
                        //  el usuario uso un criterio: 'xxx o yyy o zzz'
                        sItemValue         = sItemValue.Replace(" \'o\' ", " or " + sItemName + " = ");
                        sItemValue         = sItemValue.Replace(" \'O\' ", " or " + sItemName + " = ");
                        sCriterioItemForma = ("(" + (sItemName + (" = " + (sItemValue + ")"))));
                    }
                    else
                    {
                        sItemValue = sItemValue.Replace("'", "");
                        sItemValue = sItemValue.Replace("o", "");
                        sItemValue = sItemValue.Replace("O", "");

                        // ahora tenemos solo las fechas; las grabamos en un array

                        string[] words = sItemValue.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                        bool first = true;

                        foreach (string f in words)
                        {
                            DateTime fecha;

                            if (DateTime.TryParse(f, out fecha))
                            {
                                if (first)
                                {
                                    sCriterioItemForma += "(" +
                                                          "(" +
                                                          sItemName.Replace("'", "") + " == " +
                                                          " DateTime'" + fecha.ToString("yyyy-MM-dd H:m:s") +
                                                          "')";
                                }
                                else
                                {
                                    sCriterioItemForma += " Or " +
                                                          "(" +
                                                          sItemName.Replace("'", "") + " == " +
                                                          " DateTime'" + fecha.ToString("yyyy-MM-dd H:m:s") +
                                                          "')";
                                }

                                first = false;
                            }
                        }
                        sCriterioItemForma += ")";
                    }
                }
                else if ((((sItemValue.IndexOf(">") + 1)
                           > 0) ||
                          ((sItemValue.IndexOf("<") + 1)
                           > 0)))
                {
                    //  el usuario uso un criterio: '< 500' o '> 500'
                    if (!linqToEntities)
                    {
                        sItemValue         = sItemValue.Replace("\'>\'", ">");
                        sItemValue         = sItemValue.Replace("\'<\'", "<");
                        sCriterioItemForma = ("(" + (sItemName + (" " + (sItemValue + ")"))));
                    }
                    else
                    {
                        DateTime fecha;

                        sItemValue = sItemValue.Replace("'", "");
                        // para separar por whitespace (es decir, un blanco) y omitir blancos sucesivos (ej: 'manuel   rivera')
                        string[] words = sItemValue.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                        if (!DateTime.TryParse(words[1], out fecha))
                        {
                            // cómo terminar con error ???
                        }

                        sCriterioItemForma += "(" + sItemName.Replace("'", "") + " " + words[0] + " DateTime'" + fecha.ToString("yyyy-MM-dd H:m:s") + "')";
                    }
                }
                else
                {
                    //  el usuario indico simplemente una fecha
                    if (!linqToEntities)
                    {
                        sCriterioItemForma = ("("
                                              + (sItemName + (" = "
                                                              + (sItemValue + ")"))));
                    }
                    else
                    {
                        DateTime fecha;

                        if (!DateTime.TryParse(sItemValue.Replace("'", ""), out fecha))
                        {
                            // cómo terminar con error ???
                        }

                        sCriterioItemForma += "(" + sItemName + " == DateTime'" + fecha.ToString("yyyy-MM-dd H:m:s") + "')";
                    }
                }
                break;

            case "String":
                sCriterioItemForma = ("("
                                      + (sItemValue + ")"));
                break;

            case "Numeric":
                sItemValue = sItemValue.Replace(",", ".");
                if ((((sItemValue.IndexOf("entre") + 1)
                      > 0) ||
                     (((sItemValue.IndexOf("Entre") + 1)
                       > 0) ||
                      ((sItemValue.IndexOf("ENTRE") + 1)
                       > 0))))
                {
                    //  el usuario uso un criterio: 'entre xxx y zzz'
                    sItemValue         = sItemValue.Replace("entre", "between");
                    sItemValue         = sItemValue.Replace("Entre", "between");
                    sItemValue         = sItemValue.Replace("ENTRE", "between");
                    sItemValue         = sItemValue.Replace("y", "and");
                    sItemValue         = sItemValue.Replace("Y", "and");
                    sCriterioItemForma = ("("
                                          + (sItemName + (" "
                                                          + (sItemValue + ")"))));
                }
                else if ((((sItemValue.IndexOf(" o ") + 1)
                           > 0) ||
                          ((sItemValue.IndexOf(" O ") + 1)
                           > 0)))
                {
                    //  el usuario uso un criterio: 'xxx o yyy o zzz'
                    sItemValue = sItemValue.Replace(" o ", (" or "
                                                            + (sItemName + " = ")));
                    sItemValue = sItemValue.Replace(" O ", (" or "
                                                            + (sItemName + " = ")));
                    sCriterioItemForma = ("("
                                          + (sItemName + (" = "
                                                          + (sItemValue + ")"))));
                }
                else if ((((sItemValue.IndexOf(">") + 1)
                           > 0) ||
                          ((sItemValue.IndexOf("<") + 1)
                           > 0)))
                {
                    //  el usuario uso un criterio: '< 500' o '> 500'
                    sCriterioItemForma = ("("
                                          + (sItemName + (" "
                                                          + (sItemValue + ")"))));
                }
                else
                {
                    //  el usuario indico simplemente un monto
                    sCriterioItemForma = ("("
                                          + (sItemName + (" = "
                                                          + (sItemValue + ")"))));
                }
                break;
            }
            break;

        case "ListBox":

            System.Web.UI.WebControls.ListBox MyWebControlListBox =
                (System.Web.UI.WebControls.ListBox)MyWebServerControl;
            int i;
            sCriterioItemForma = "";

            for (i = 0; i <= MyWebControlListBox.Items.Count - 1; i++)
            {
                if (MyWebControlListBox.Items[i].Selected)
                {
                    switch (sItemType)
                    {
                    case "String":
                        if (sCriterioItemForma == "")
                        {
                            if (!this.linqToEntities)
                            {
                                sCriterioItemForma = "(" + sItemName + " = \'" + MyWebControlListBox.Items[i].Value + "\'";
                            }
                            else
                            {
                                sCriterioItemForma = "(" + sItemName + " IN {\'" + MyWebControlListBox.Items[i].Value + "\'";
                            }
                        }
                        else
                        {
                            if (!this.linqToEntities)
                            {
                                sCriterioItemForma = sCriterioItemForma + " Or " + sItemName + " = \'" + MyWebControlListBox.Items[i].Value + "\'";
                            }
                            else
                            {
                                sCriterioItemForma = sCriterioItemForma + ", '" + MyWebControlListBox.Items[i].Value + "\'";
                            }
                        }
                        break;

                    default:
                        if (sCriterioItemForma == "")
                        {
                            if (!this.linqToEntities)
                            {
                                sCriterioItemForma = "(" + sItemName + " = " + MyWebControlListBox.Items[i].Value;
                            }
                            else
                            {
                                sCriterioItemForma = "(" + sItemName + " IN {" + MyWebControlListBox.Items[i].Value;
                            }
                        }
                        else
                        {
                            if (!this.linqToEntities)
                            {
                                sCriterioItemForma = sCriterioItemForma + " Or " + sItemName + " = " + MyWebControlListBox.Items[i].Value;
                            }
                            else
                            {
                                sCriterioItemForma = sCriterioItemForma + ", " + MyWebControlListBox.Items[i].Value;
                            }
                        }
                        break;
                    }
                }
            }
            if ((sCriterioItemForma != ""))
            {
                if (!this.linqToEntities)
                {
                    sCriterioItemForma = (sCriterioItemForma + ")");
                }
                else
                {
                    sCriterioItemForma = (sCriterioItemForma + "})");
                }
            }
            break;

        case "DropDownList":
            System.Web.UI.WebControls.DropDownList MyWebControlDropDownList =
                (System.Web.UI.WebControls.DropDownList)MyWebServerControl;
            sCriterioItemForma = "";
            switch (sItemType)
            {
            case "String":
                sCriterioItemForma = ("("
                                      + (sItemName + (" = \'"
                                                      + (MyWebControlDropDownList.SelectedItem.Value + "\'"))));
                break;

            default:
                sCriterioItemForma = ("("
                                      + (sItemName + (" = " + MyWebControlDropDownList.SelectedItem.Value)));
                break;
            }
            if ((sCriterioItemForma != ""))
            {
                sCriterioItemForma = (sCriterioItemForma + ")");
            }
            break;
        }
    }
Esempio n. 51
0
    public string ChekControl(System.Web.UI.Control MyWebServerControl)
    {
        string sCriterioItemForma = "";

        // ahora debemos obtener el nombre de la columna y su type. Para hacerlo, revisamos el nombre del control (ID) y separamos en partes por '-'
        // nótese la forma del ID: Sql_CuentasBancarias_Cia_Numeric; ahora, cuando adaptamos esta función a entity sql, el ID del control puede
        // ser más complejo, por ejemplo: Sql_it_Chequera_CuentasBancarias_Cia_Numeric; en este ejemplo, el nombre de la 'columna' debe ser:
        // it.Chequera.CuentasBancaria.Cia y su tipo Numeric ...

        string nombreAspNetServerControl = MyWebServerControl.ID;

        string[] x = nombreAspNetServerControl.Split('_');

        int cantPartes   = x.Length;
        int parteTratada = 0;

        string sNombreItem = "";
        string sTipoItem   = "";

        foreach (string xx in x)
        {
            parteTratada++;

            if (parteTratada == 1)
            {
                // debe ser 'Sql'; continuamos
                continue;
            }

            // la última parte corresponde siempre al type: string, date, numeric ...
            if (parteTratada == cantPartes)
            {
                sTipoItem = xx;
                continue;
            }

            if (sNombreItem == "")
            {
                sNombreItem = xx;
            }
            else
            {
                sNombreItem += "." + xx;
            }
        }


        switch (MyWebServerControl.GetType().Name.ToString())
        {
        case "TextBox":
            System.Web.UI.WebControls.TextBox MyWebControlTextBox = (System.Web.UI.WebControls.TextBox)MyWebServerControl;

            // eliminamos algún /r/n (new line) que a veces queda en el control
            string texto = MyWebControlTextBox.Text;
            texto = texto.Replace("\n", String.Empty);
            texto = texto.Replace("\r", String.Empty);
            texto = texto.Replace("\t", String.Empty);

            if ((texto != ""))
            {
                BuildCriteria(MyWebServerControl, sNombreItem, MyWebControlTextBox.Text, sTipoItem, ref sCriterioItemForma);
            }
            break;

        case "CheckBox":
            System.Web.UI.WebControls.CheckBox MyWebControlCheckbox =
                (System.Web.UI.WebControls.CheckBox)MyWebServerControl;
            if ((MyWebControlCheckbox.Enabled && MyWebControlCheckbox.Checked))
            {
                sCriterioItemForma = "(" + sNombreItem + " = 1)";
            }
            else if (MyWebControlCheckbox.Enabled && !MyWebControlCheckbox.Checked)
            {
                sCriterioItemForma = "(" + sNombreItem + " = 0)";
            }
            break;

        case "ListBox":
            System.Web.UI.WebControls.ListBox MyWebControlListBox =
                (System.Web.UI.WebControls.ListBox)MyWebServerControl;
            if (MyWebControlListBox.SelectedIndex > -1)
            {
                //  notese como pasamos "" como valor del par�metro sItemValue,
                //  pues el ListBox no tiene una propiedad Text. En ves de
                //  ello, el usuario selecciona uno o m�s rows en este control.

                BuildCriteria(MyWebServerControl, sNombreItem, "", sTipoItem, ref sCriterioItemForma);
            }
            break;

        case "DropDownList":
            System.Web.UI.WebControls.DropDownList MyWebControlDropDownList =
                (System.Web.UI.WebControls.DropDownList)MyWebServerControl;
            //  nuestra convenci�n es que un DropDownList cuyo texto
            //  seleccionado es "", 'no est� seleccionado'. La raz�n de
            //  esto es que en Asp.Net un DropDownList SIEMPRE est�
            //  seleccionado (!).
            if (((MyWebControlDropDownList.SelectedIndex > -1) &&
                 (MyWebControlDropDownList.SelectedValue != "")))
            {
                //  notese como pasamos "" como valor del par�metro sItemValue,
                //  pues el ListBox no tiene una propiedad Text. En ves de
                //  ello, el usuario selecciona uno o m�s rows en este control.

                BuildCriteria(MyWebServerControl, sNombreItem, "", sTipoItem, ref sCriterioItemForma);
            }
            break;
        }
        return(sCriterioItemForma);
    }
        /// <summary>
        /// Retrieves the cache key based on the current property values.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="control"></param>
        /// <param name="container"></param>
        /// <param name="getDefaultKey"></param>
        /// <returns></returns>
        public string GetCacheKey(System.Web.HttpContext context, System.Web.UI.Control control, object container, Converter <string, string> getDefaultKey)
        {
            string cacheKey = KeyFormat;

            if (Parameters != null && Parameters.Count > 0)
            {
                // use the parameters collection to build the dependency
                IOrderedDictionary values = Parameters.GetValues(context, control);

                if (container != null)
                {
                    // process CacheItemParameter objects, lookup the value based on the container
                    foreach (Parameter param in Parameters)
                    {
                        if (param is CacheItemParameter)
                        {
                            string format       = (param as CacheItemParameter).Format;
                            string propertyName = (param as CacheItemParameter).PropertyName;
                            string result       = DataBinder.Eval(container, propertyName, format);

                            if (!string.IsNullOrEmpty(result))
                            {
                                values[param.Name] = result;
                            }
                        }
                    }
                }

                if (!string.IsNullOrEmpty(KeyFormat))
                {
                    foreach (DictionaryEntry entry in values)
                    {
                        if (entry.Key != null)
                        {
                            string key = entry.Key.ToString().Trim();

                            if (!key.StartsWith("@"))
                            {
                                key = "@" + key;
                            }

                            cacheKey = Regex.Replace(cacheKey, key, "{0}".FormatWith(entry.Value), RegexOptions.IgnoreCase);
                        }
                    }
                }
            }
            else if (!string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(PropertyName))
            {
                string result = null;

                if (container != null)
                {
                    try
                    {
                        result = DataBinder.Eval(container, PropertyName, "{0}");
                    }
                    catch (Exception e)
                    {
                        Tracing.FrameworkError("CacheKeyDependency", "GetCacheKey", "Invalid cache parameter settings.");
                        Tracing.FrameworkError("CacheKeyDependency", "GetCacheKey", e.ToString());
                    }
                }

                // use this object to build the dependency
                string key = Name.Trim();

                if (!key.StartsWith("@"))
                {
                    key = "@" + key;
                }

                cacheKey = Regex.Replace(cacheKey, key, result ?? string.Empty, RegexOptions.IgnoreCase);
            }

            if (string.IsNullOrEmpty(cacheKey))
            {
                // could not find a suitable cacheKey from the parameters, build a default key
                cacheKey = "Adxstudio:{0}:ID={1}".FormatWith(control.GetType().FullName, control.ID);

                // provide an opportunity to override this suggested default
                if (getDefaultKey != null)
                {
                    cacheKey = getDefaultKey(cacheKey);
                }
            }

            if (VaryByUser)
            {
                IIdentity identity;

                if (TryGetCurrentIdentity(out identity) && identity.IsAuthenticated)
                {
                    cacheKey += ":Identity={0}".FormatWith(identity.Name);
                }
            }

            if (!string.IsNullOrEmpty(VaryByParam))
            {
                foreach (string section in VaryByParam.Split(_varySeparator))
                {
                    string param = section.Trim();
                    cacheKey += ":{0}={1}".FormatWith(param, context.Request[param]);
                }
            }

            return(cacheKey);
        }
Esempio n. 53
0
 public static void JsLanzarExecutarScriptRecargarPagina(System.Web.UI.Control oControl, String key, String script, Boolean CabeceraScript)
 {
     ScriptManager.RegisterClientScriptBlock(oControl, oControl.GetType(), key, script, CabeceraScript);
 }
Esempio n. 54
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="control"></param>
        /// note: made public so that RAMP project can use it!
        public static void ClearDataGridControls(System.Web.UI.Control control)
        {
            // translated from VB: http://forums.asp.net/p/466278/466278.aspx
            for (int i = control.Controls.Count - 1; i >= 0; i--)
            {
                ClearDataGridControls(control.Controls[i]);
            }

            if (!(control is System.Web.UI.WebControls.TableCell))
            {
                Type t = control.GetType();
                if (t.GetProperty("SelectedItem") != null)
                {
                    System.Web.UI.LiteralControl literal = new System.Web.UI.LiteralControl();
                    control.Parent.Controls.Add(literal);
                    try
                    {
                        literal.Text = t.GetProperty("SelectedItem").GetValue(control, null).ToString();
                    }
                    catch
                    { }
                    control.Parent.Controls.Remove(control);
                }
                else if (t.GetProperty("Text") != null)
                {
                    System.Web.UI.LiteralControl literal = new System.Web.UI.LiteralControl();
                    control.Parent.Controls.Add(literal);
                    try
                    {
                        literal.Text = t.GetProperty("Text").GetValue(control, null).ToString();
                    }
                    catch
                    { }
                    control.Parent.Controls.Remove(control);
                }
                else if (control is LinkButton)
                {
                    control.Parent.Controls.Add(new LiteralControl((control as LinkButton).Text));
                    control.Parent.Controls.Remove(control);
                }
                else if (control is ImageButton)
                {
                    control.Parent.Controls.Add(new LiteralControl((control as ImageButton).AlternateText));
                    control.Parent.Controls.Remove(control);
                }
                else if (control is HyperLink)
                {
                    control.Parent.Controls.Add(new LiteralControl((control as HyperLink).Text));
                    control.Parent.Controls.Remove(control);
                }
                else if (control is DropDownList)
                {
                    control.Parent.Controls.Add(new LiteralControl((control as DropDownList).SelectedItem.Text));
                    control.Parent.Controls.Remove(control);
                }
                else if (control is CheckBox)
                {
                    control.Parent.Controls.Add(new LiteralControl((control as CheckBox).Checked ? "True" : "False"));
                    control.Parent.Controls.Remove(control);
                }
            }
        } //
Esempio n. 55
0
        /// <summary>
        /// 把实体成员的值设置到控件上
        /// </summary>
        /// <param name="field"></param>
        /// <param name="control"></param>
        /// <param name="canSave"></param>
        protected virtual void SetFormItem(FieldItem field, System.Web.UI.Control control, Boolean canSave)
        {
            if (field == null || control == null)
            {
                return;
            }

            String toolTip = String.IsNullOrEmpty(field.Description) ? field.Name : field.Description;

            if (field.IsNullable)
            {
                toolTip = String.Format("请填写{0}!", toolTip);
            }
            else
            {
                toolTip = String.Format("必须填写{0}!", toolTip);
            }

            if (control is Label)
            {
                toolTip = null;
            }

            if (control is ExtAspNet.ControlBase)
            {
                ExtAspNet.ControlBase wc = control as ExtAspNet.ControlBase;

                // 设置ToolTip
                //if (String.IsNullOrEmpty(wc.ToolTip) && !String.IsNullOrEmpty(toolTip)) wc.ToolTip = toolTip;

                //// 必填项
                //if (!field.IsNullable) SetNotAllowNull(field, control, canSave);

                // 设置只读,只有不能保存时才设置,因为一般都不是只读,而前端可能自己设置了控件为只读,这种情况下这里再设置就会修改前端的意思
                if (!canSave)
                {
                    if (wc is ExtAspNet.TextBox)
                    {
                        (wc as TextBox).Enabled = !canSave;
                    }
                    else
                    {
                        wc.Enabled = canSave;
                    }
                }

                // 分控件处理
                if (wc is TextBox || wc is DatePicker)
                {
                    SetFormItemTextBox(field, wc as RealTextField, canSave);
                }
                else if (wc is Label)
                {
                    SetFormItemLabel(field, wc as Label, canSave);
                }
                else if (wc is RadioButton)
                {
                    SetFormItemRadioButton(field, wc as RadioButton, canSave);
                }
                else if (wc is CheckBox)
                {
                    SetFormItemCheckBox(field, wc as CheckBox, canSave);
                }
                else if (wc is DropDownList)
                {
                    SetFormItemListControl(field, wc as DropDownList, canSave);
                }
                else
                {
                    SetControlValue(control as ControlBase, Entity[field.Name]);
                }
            }
            else
            {
                SetControlValue(control as ControlBase, Entity[field.Name]);

                PropertyInfoX pix = PropertyInfoX.Create(control.GetType(), "ToolTip");
                if (pix != null && String.IsNullOrEmpty((String)pix.GetValue(control)))
                {
                    pix.SetValue(control, toolTip);
                }
            }
        }
Esempio n. 56
0
 /// <summary>
 /// 填充表单
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="control"></param>
 public static void FillForm(WebUI.Control control, Object entity)
 {
     if (entity == null || control == null)
     {
         return;
     }
     PropertyInfo[] propertyList = entity.GetProperties();
     foreach (PropertyInfo pi in propertyList)
     {
         WebUI.Control ctl = control.FindControl(string.Format(IdFormat, pi.Name));
         if (ctl == null)
         {
             continue;
         }
         Type ctlType = ctl.GetType();
         #region 处理服务器控件
         if (ctlType == typeof(WebUI.WebControls.TextBox))//文本框
         {
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 ((WebUI.WebControls.TextBox)ctl).Text = entity.GetPropertyValue(pi.Name).ToString();
             }
         }
         else if (ctlType == typeof(WebUI.WebControls.Image))//图片
         {
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 string imageUrl = entity.GetPropertyValue(pi.Name).ToString();
                 if (!string.IsNullOrEmpty(imageUrl))
                 {
                     ((WebUI.WebControls.Image)ctl).ImageUrl = imageUrl;
                 }
             }
         }
         else if (ctlType == typeof(WebUI.WebControls.DropDownList))//选择框
         {
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 ((WebUI.WebControls.DropDownList)ctl).SelectedValue = entity.GetPropertyValue(pi.Name).ToString();
             }
         }
         else if (ctlType == typeof(WebUI.WebControls.HiddenField))//隐藏域
         {
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 ((WebUI.WebControls.HiddenField)ctl).Value = entity.GetPropertyValue(pi.Name).ToString();
             }
         }
         else if (ctlType == typeof(WebUI.WebControls.RadioButton))//单选框
         {
             WebUI.WebControls.RadioButton rb = (WebUI.WebControls.RadioButton)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 rb.Checked = entity.GetPropertyValue(pi.Name).ToString() == rb.Text ? true : false;
             }
         }
         else if (ctlType == typeof(WebUI.WebControls.CheckBox))//复选框
         {
             WebUI.WebControls.CheckBox ck = (WebUI.WebControls.CheckBox)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 ck.Checked = entity.GetPropertyValue(pi.Name).ToString() == ck.Text ? true : false;
             }
         }
         else if (ctlType == typeof(WebUI.WebControls.CheckBoxList))//复选框列表
         {
             WebUI.WebControls.CheckBoxList ck = (WebUI.WebControls.CheckBoxList)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 string sel = entity.GetPropertyValue(pi.Name).ToString();
                 foreach (WebUI.WebControls.ListItem li in ck.Items)
                 {
                     if (sel.IndexOf(",") > -1 && (sel.IndexOf(li.Value + ",") > -1 || sel.IndexOf("," + li.Value) > -1))
                     {
                         li.Selected = true;
                     }
                     else if (sel.IndexOf(",") == -1 && sel == li.Value)
                     {
                         li.Selected = true;
                     }
                     else
                     {
                         li.Selected = false;
                     }
                 }
             }
         }
         else if (ctlType == typeof(WebUI.WebControls.RadioButtonList))//单框列表
         {
             WebUI.WebControls.RadioButtonList ck = (WebUI.WebControls.RadioButtonList)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 ck.SelectedValue = entity.GetPropertyValue(pi.Name).ToString();
             }
         }
         else if (ctlType == typeof(WebUI.WebControls.ListBox))//列表框
         {
             WebUI.WebControls.ListBox ck = (WebUI.WebControls.ListBox)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 string sel = entity.GetPropertyValue(pi.Name).ToString();
                 foreach (WebUI.WebControls.ListItem li in ck.Items)
                 {
                     if (sel.IndexOf(",") > -1 && (sel.IndexOf(li.Value + ",") > -1 || sel.IndexOf("," + li.Value) > -1))
                     {
                         li.Selected = true;
                     }
                     else if (sel.IndexOf(",") == -1 && sel == li.Value)
                     {
                         li.Selected = true;
                     }
                     else
                     {
                         li.Selected = false;
                     }
                 }
             }
         }
         #endregion
         #region 处理不同Html控件
         else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputText))//文本域
         {
             WebUI.HtmlControls.HtmlInputText ct = (WebUI.HtmlControls.HtmlInputText)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 ct.Value = entity.GetPropertyValue(pi.Name).ToString();
             }
         }
         else if (ctlType == typeof(WebUI.HtmlControls.HtmlTextArea))//文本域
         {
             WebUI.HtmlControls.HtmlTextArea ct = (WebUI.HtmlControls.HtmlTextArea)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 ct.Value = entity.GetPropertyValue(pi.Name).ToString();
             }
         }
         else if (ctlType == typeof(WebUI.HtmlControls.HtmlSelect))//选择域
         {
             WebUI.HtmlControls.HtmlSelect ct = (WebUI.HtmlControls.HtmlSelect)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 for (int i = 0; i < ct.Items.Count; i++)
                 {
                     if (ct.Items[i].Value == entity.GetPropertyValue(pi.Name).ToString())
                     {
                         ct.SelectedIndex = i;
                     }
                 }
             }
         }
         else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputHidden))////隐藏域
         {
             WebUI.HtmlControls.HtmlInputHidden ct = (WebUI.HtmlControls.HtmlInputHidden)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 ct.Value = entity.GetPropertyValue(pi.Name).ToString();
             }
         }
         else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputRadioButton))//单选域
         {
             WebUI.HtmlControls.HtmlInputRadioButton rb = (WebUI.HtmlControls.HtmlInputRadioButton)ctl;
             if (rb.Checked && entity.GetPropertyValue(pi.Name) != null)
             {
                 rb.Checked = entity.GetPropertyValue(pi.Name).ToString() == rb.Value ? true : false;
             }
         }
         else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputCheckBox))//复选域
         {
             WebUI.HtmlControls.HtmlInputCheckBox ck = (WebUI.HtmlControls.HtmlInputCheckBox)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 if (entity.GetPropertyValue(pi.Name).ToString().IndexOf("," + ck.Value) != -1)
                 {
                     ck.Checked = true;
                 }
             }
         }
         else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputPassword))//密码域
         {
             WebUI.HtmlControls.HtmlInputPassword ck = (WebUI.HtmlControls.HtmlInputPassword)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 ck.Value = entity.GetPropertyValue(pi.Name).ToString();
             }
         }
         #endregion
     }
 }
Esempio n. 57
0
        /// <summary>
        /// 填充model
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="control"></param>
        public static void FillModel(Object entity, WebUI.Control control)
        {
            if (entity == null || control == null)
            {
                return;
            }
            NameValueCollection formData = HttpContext.Current.Request.Form;

            PropertyInfo[] propertyList = entity.GetProperties();
            foreach (PropertyInfo pi in propertyList)
            {
                string        ctlId = string.Format(IdFormat, pi.Name);
                WebUI.Control ctl   = control.FindControl(ctlId);
                if (ctl == null)
                {
                    #region 处理HMTL标签
                    if (formData[ctlId] != null)
                    {
                        entity.SetPropertyValue(pi.Name, formData[ctlId]);
                    }
                    #endregion
                    continue;
                }
                Type ctlType = ctl.GetType();

                #region 处理服务器控件
                if (ctlType == typeof(WebUI.WebControls.TextBox))//文本框
                {
                    entity.SetPropertyValue(pi.Name, ((WebUI.WebControls.TextBox)ctl).Text);
                }
                else if (ctlType == typeof(WebUI.WebControls.Image))//图片
                {
                    entity.SetPropertyValue(pi.Name, ((WebUI.WebControls.Image)ctl).ImageUrl);
                }
                else if (ctlType == typeof(WebUI.WebControls.DropDownList))//选择框
                {
                    entity.SetPropertyValue(pi.Name, ((WebUI.WebControls.DropDownList)ctl).SelectedValue);
                }
                else if (ctlType == typeof(WebUI.WebControls.HiddenField))//隐藏域
                {
                    entity.SetPropertyValue(pi.Name, ((WebUI.WebControls.HiddenField)ctl).Value);
                }
                else if (ctlType == typeof(WebUI.WebControls.RadioButton))//单选框
                {
                    WebUI.WebControls.RadioButton rb = (WebUI.WebControls.RadioButton)ctl;

                    if (rb.Checked)
                    {
                        entity.SetPropertyValue(pi.Name, rb.Text);
                    }
                    else
                    {
                        entity.SetPropertyValue(pi.Name, "");
                    }
                }
                else if (ctlType == typeof(WebUI.WebControls.CheckBox))//复选框
                {
                    WebUI.WebControls.CheckBox ck = (WebUI.WebControls.CheckBox)ctl;
                    if (ck.Checked)
                    {
                        entity.SetPropertyValue(pi.Name, ck.Text);
                    }
                    else
                    {
                        entity.SetPropertyValue(pi.Name, "");
                    }
                }
                else if (ctlType == typeof(WebUI.WebControls.CheckBoxList))//复选框列表
                {
                    WebUI.WebControls.CheckBoxList ck = (WebUI.WebControls.CheckBoxList)ctl;
                    string rs = "";
                    foreach (WebUI.WebControls.ListItem li in ck.Items)
                    {
                        if (li.Selected)
                        {
                            rs += "," + li.Value;
                        }
                    }
                    if (rs.Length > 1)
                    {
                        rs = rs.Substring(1);
                    }
                    entity.SetPropertyValue(pi.Name, rs);
                }
                else if (ctlType == typeof(WebUI.WebControls.RadioButtonList))//单框列表
                {
                    WebUI.WebControls.RadioButtonList ck = (WebUI.WebControls.RadioButtonList)ctl;
                    entity.SetPropertyValue(pi.Name, ck.SelectedValue);
                }
                else if (ctlType == typeof(WebUI.WebControls.ListBox))//列表框
                {
                    WebUI.WebControls.ListBox ck = (WebUI.WebControls.ListBox)ctl;
                    string rs = "";
                    foreach (WebUI.WebControls.ListItem li in ck.Items)
                    {
                        if (li.Selected)
                        {
                            rs += "," + li.Value;
                        }
                    }
                    if (rs.Length > 1)
                    {
                        rs = rs.Substring(1);
                    }
                    entity.SetPropertyValue(pi.Name, rs);
                }
                #endregion
                #region 处理不同Html控件
                else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputText))//文本域
                {
                    WebUI.HtmlControls.HtmlInputText ct = (WebUI.HtmlControls.HtmlInputText)ctl;
                    entity.SetPropertyValue(pi.Name, ct.Value);
                }
                else if (ctlType == typeof(WebUI.HtmlControls.HtmlTextArea))//文本域
                {
                    WebUI.HtmlControls.HtmlTextArea ct = (WebUI.HtmlControls.HtmlTextArea)ctl;
                    entity.SetPropertyValue(pi.Name, ct.Value);
                }
                else if (ctlType == typeof(WebUI.HtmlControls.HtmlSelect))//选择域
                {
                    WebUI.HtmlControls.HtmlSelect ct = (WebUI.HtmlControls.HtmlSelect)ctl;
                    entity.SetPropertyValue(pi.Name, ct.Items[ct.SelectedIndex].Value);
                }
                else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputHidden))////隐藏域
                {
                    WebUI.HtmlControls.HtmlInputHidden ct = (WebUI.HtmlControls.HtmlInputHidden)ctl;
                    entity.SetPropertyValue(pi.Name, ct.Value);
                }
                else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputRadioButton))//单选域
                {
                    WebUI.HtmlControls.HtmlInputRadioButton rb = (WebUI.HtmlControls.HtmlInputRadioButton)ctl;
                    if (rb.Checked)
                    {
                        entity.SetPropertyValue(pi.Name, rb.Value);
                    }
                }
                else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputCheckBox))//复选域
                {
                    WebUI.HtmlControls.HtmlInputCheckBox ck = (WebUI.HtmlControls.HtmlInputCheckBox)ctl;
                    if (ck.Checked)
                    {
                        entity.SetPropertyValue(pi.Name, ck.Value);
                    }
                }
                else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputPassword))//密码域
                {
                    WebUI.HtmlControls.HtmlInputPassword ck = (WebUI.HtmlControls.HtmlInputPassword)ctl;
                    entity.SetPropertyValue(pi.Name, ck.Value);
                }
                #endregion
            }
        }
Esempio n. 58
0
 /// <summary>
 /// 执行javascript方法
 /// </summary>
 /// <param name="page"></param>
 /// <param name="script"></param>
 /// <param name="addScriptTags"></param>
 public static void SetScript(System.Web.UI.Control control, string script, bool addScriptTags)
 {
     ScriptManager.RegisterClientScriptBlock(control, control.GetType(), "", script, addScriptTags);
 }
Esempio n. 59
0
    public void ReadStateFromFile(Page AspNetPage, ControlCollection MyControlCollection)
    {
        //  intentamos leer el archivo que corresponde a la p�gina y usuario para rescatar el state
        if (((_UserName == "") || (_PageName == "")))
        {
            return;
        }
        string fileName = string.Concat(_PageName, "-", _UserName);
        string filePath = HttpContext.Current.Server.MapPath(("~/keepstatefiles/" + fileName));
        string contents = "";

        try
        {
            contents = File.ReadAllText(filePath);
        }
        catch (Exception ex)
        {
        }
        if ((contents == ""))
        {
            return;
        }
        string[] splitout = contents.Split('¦');
        foreach (string Split in splitout)
        {
            int nPosSignoIgual = Split.IndexOf("=");
            if ((nPosSignoIgual > 0))
            {
                string sNombreControl = Split.Substring(0, nPosSignoIgual);
                string sContenido     = Split.Substring((Split.Length + 1 - (Split.Length - nPosSignoIgual)));
                System.Web.UI.Control MyWebServerControl = FindControlRecursive(AspNetPage, sNombreControl);
                if ((MyWebServerControl == null))
                {
                    // TODO: Continue For... Warning!!! not translated
                    continue;
                }
                switch (MyWebServerControl.GetType().Name.ToString())
                {
                case "TextBox":
                    System.Web.UI.WebControls.TextBox MyWebControlTextBox =
                        (System.Web.UI.WebControls.TextBox)MyWebServerControl;
                    //  este caso es f�cil pues el text box solo contiene un valor (ListBox puede tener
                    //  mucho items seleccionados)
                    MyWebControlTextBox.Text = sContenido;
                    break;

                case "CheckBox":
                    System.Web.UI.WebControls.CheckBox MyWebControlCheckbox =
                        (System.Web.UI.WebControls.CheckBox)MyWebServerControl;
                    if ((sContenido == "1"))
                    {
                        MyWebControlCheckbox.Checked = true;
                    }
                    else
                    {
                        MyWebControlCheckbox.Checked = false;
                    }
                    break;

                case "RadioButton":
                    System.Web.UI.WebControls.RadioButton MyWebControlRadioButton =
                        (System.Web.UI.WebControls.RadioButton)MyWebServerControl;
                    if ((sContenido == "1"))
                    {
                        MyWebControlRadioButton.Checked = true;
                    }
                    else
                    {
                        MyWebControlRadioButton.Checked = false;
                    }
                    break;

                case "ListBox":
                {
                    System.Web.UI.WebControls.ListBox MyWebControlListBox =
                        (System.Web.UI.WebControls.ListBox)MyWebServerControl;
                    string[] sArrayOfStrings = sContenido.Split(';');
                    foreach (string MyString in sArrayOfStrings)
                    {
                        foreach (ListItem MyListItem in MyWebControlListBox.Items)
                        {
                            if ((MyListItem.Text == MyString))
                            {
                                MyListItem.Selected = true;
                            }
                        }
                    }
                    break;
                }

                case "CheckBoxList":
                {
                    System.Web.UI.WebControls.CheckBoxList MyWebControlCheckBoxList = (System.Web.UI.WebControls.CheckBoxList)MyWebServerControl;
                    string[] sArrayOfStrings = sContenido.Split(';');
                    foreach (string MyString in sArrayOfStrings)
                    {
                        foreach (ListItem MyListItem in MyWebControlCheckBoxList.Items)
                        {
                            if ((MyListItem.Text == MyString))
                            {
                                MyListItem.Selected = true;
                            }
                        }
                    }
                    break;
                }

                case "DropDownList":
                    System.Web.UI.WebControls.DropDownList MyWebControlDropDownList =
                        (System.Web.UI.WebControls.DropDownList)MyWebServerControl;
                    MyWebControlDropDownList.SelectedValue = sContenido;
                    break;
                }
            }
        }
    }
Esempio n. 60
0
    public void DisplayAJAXMessage(System.Web.UI.Control page, string msg)
    {
        string myScript = String.Format("alert('{0}');", msg);

        ScriptManager.RegisterStartupScript(page, page.GetType(), "MyScript", myScript, true);
    }