FindControl() private method

private FindControl ( string id ) : Control
id string
return Control
コード例 #1
3
ファイル: TabPanelAttribute.cs プロジェクト: dpawatts/zeus
        public override Control AddTo(Control container)
        {
            // If the current container doesn't already contain a TabControl, create one now.
            CustomTabPanel tabControl = container.FindControl("TabControl") as CustomTabPanel;
            if (tabControl == null)
            {
                tabControl = new CustomTabPanel { ID = "TabControl" };
                if (container is ContentPanel)
                    ((ContentPanel) container).ContentControls.Add(tabControl);
                else
                    container.Controls.Add(tabControl);
            }

            Panel tabItem = new Panel
            {
                AutoScroll = true,
                AutoHeight = true,
                AutoWidth = true,
                ID = "tabItem" + Name,
                Title = Title,
                BodyStyle = "padding:5px"
            };
            tabControl.Items.Add(tabItem);
            return tabItem;
        }
コード例 #2
0
        public void ControlParameter(Control _control, string title, string icon, string value, int record)
        {
            //Control _controlsTitle = _control.FindControl("lblTitle");
            //if (_controlsTitle != null)
            //{
            //    Type objTypeTitle = _controlsTitle.GetType();
            //    if (objTypeTitle.Name == "Label")
            //    {
            //        Label objlbl = (Label)_controlsTitle;
            //        objlbl.Text = title;
            //    }
            //}

            Control _controlsTitle = _control.FindControl("hddTitle");
            if (_controlsTitle != null)
            {
                Type objTypeTitle = _controlsTitle.GetType();
                if (objTypeTitle.Name == "HiddenField")
                {
                    HiddenField objlbl = (HiddenField)_controlsTitle;
                    objlbl.Value = title;
                }
            }

            Control _controlsIcon = _control.FindControl("imgIcon");
            if (_controlsIcon != null)
            {
                Type objTypeIcon = _controlsIcon.GetType();
                if (objTypeIcon.Name == "Image")
                {
                    Image objimg = (Image)_controlsIcon;
                    objimg.ImageUrl = "~/Upload/Admin_Theme/Icons/" + icon;
                }
            }


            Control _controlsValue = _control.FindControl("hddValue");
            if (_controlsValue != null)
            {
                Type objTypeValue = _controlsValue.GetType();
                if (objTypeValue.Name == "HiddenField")
                {
                    HiddenField objvalue = (HiddenField)_controlsValue;
                    objvalue.Value = value;
                }
            }

            Control _controlsRecord = _control.FindControl("hddRecord");
            if (_controlsRecord != null)
            {
                Type objTypeRecord = _controlsRecord.GetType();
                if (objTypeRecord.Name == "HiddenField")
                {
                    HiddenField objRecord = (HiddenField)_controlsRecord;
                    objRecord.Value = record.ToString();
                }
            }
        }
コード例 #3
0
        public void ControlParameter(Control control, string title, string icon, string value, int record, string content)
        {
            var controlsTitle = control.FindControl("Literal1");
            if (controlsTitle != null)
            {
                var objTypeTitle = controlsTitle.GetType();
                if (objTypeTitle.Name == "Literal")
                {
                    var objlbl = (Literal)controlsTitle;
                    objlbl.Text = title;
                }
            }

            var controlsIcon = control.FindControl("imgIcon");
            if (controlsIcon != null)
            {
                var objTypeIcon = controlsIcon.GetType();
                if (objTypeIcon.Name == "Image")
                {
                    var objimg = (Image)controlsIcon;
                    objimg.ImageUrl = "~/Upload/Admin_Theme/Icons/" + icon;
                }
            }

            var controlsValue = control.FindControl("hddValue");
            if (controlsValue != null)
            {
                var objTypeValue = controlsValue.GetType();
                if (objTypeValue.Name == "HiddenField")
                {
                    var objvalue = (HiddenField)controlsValue;
                    objvalue.Value = value;
                }
            }

            var controlsRecord = control.FindControl("hddRecord");
            if (controlsRecord != null)
            {
                var objTypeRecord = controlsRecord.GetType();
                if (objTypeRecord.Name == "HiddenField")
                {
                    var objRecord = (HiddenField)controlsRecord;
                    objRecord.Value = record.ToString();
                }
            }

            var controlsContent = control.FindControl("hddContent");
            if (controlsContent != null)
            {
                var objTypeContent = controlsContent.GetType();
                if (objTypeContent.Name == "HiddenField")
                {
                    var objContent = (HiddenField)controlsContent;
                    objContent.Value = content.ToString();
                }
            }
        }
コード例 #4
0
        public void ControlParameter(Control control, string title, string icon, string value, int record, string panelId)
        {
            var controlsTitle = control.FindControl("hddTitle");
            if (controlsTitle != null)
            {
                var objTypeTitle = controlsTitle.GetType();
                if (objTypeTitle.Name == "HiddenField")
                {
                    var objlbl = (HiddenField)controlsTitle;
                    objlbl.Value = title;
                }
            }

            var controlsIcon = control.FindControl("imgIcon");
            if (controlsIcon != null)
            {
                var objTypeIcon = controlsIcon.GetType();
                if (objTypeIcon.Name == "Image")
                {
                    var objimg = (Image)controlsIcon;
                    objimg.ImageUrl = "~/Upload/Admin_Theme/Icons/" + icon;
                }
            }

            var controlsValue = control.FindControl("hddValue");
            if (controlsValue != null)
            {
                var objTypeValue = controlsValue.GetType();
                if (objTypeValue.Name == "HiddenField")
                {
                    var objvalue = (HiddenField)controlsValue;
                    objvalue.Value = value;
                }
            }

            var controlsRecord = control.FindControl("hddRecord");
            if (controlsRecord != null)
            {
                var objTypeRecord = controlsRecord.GetType();
                if (objTypeRecord.Name == "HiddenField")
                {
                    var objRecord = (HiddenField)controlsRecord;
                    objRecord.Value = record.ToString();
                }
            }

            var controlsId = control.FindControl("hdfPanelId");
            if (controlsId != null)
            {
                var objTypePnId = controlsId.GetType();
                if (objTypePnId.Name == "HiddenField")
                {
                    var objPnId = (HiddenField)controlsId;
                    objPnId.Value = panelId;
                }
            }
        }
コード例 #5
0
ファイル: MyForums.cs プロジェクト: Confirmit/Portal
        // *********************************************************************
        //  Initializeskin
        //
        /// <summary>
        /// Initialize the control template and populate the control with values
        /// </summary>
        // ***********************************************************************/
        protected override void InitializeSkin(Control skin)
        {
            IDataProviderBase dp = DataProvider.Instance();
            int LC;
            LC = dp.GetLastCount((UlterSystems.PortalLib.BusinessObjects.Person.RequestUser().ID).ToString());

            // Find the thread tracking thread list control
            threadTracking = (ThreadList)skin.FindControl("ThreadTracking");
            if (null != threadTracking)
            {
                ThreadCollection trackedThreads = Threads.GetThreadsUserIsTracking(ForumUser.Username);

                if (trackedThreads.Count > 0)
                {
                    threadTracking.DataSource = trackedThreads;
                    threadTracking.DataBind();
                }
                else
                {
                    threadTracking.Visible = false;
                    Label label = (Label)skin.FindControl("NoTrackedThreads");
                    if (null != label)
                    {
                        label.Visible = true;
                    }

                }
            }

            // Find the participated threads control
            participatedThreads = (ThreadList)skin.FindControl("ParticipatedThreads");
            LastCount = (DropDownList)skin.FindControl("LastCount");
            LastCount.SelectedIndex = (LC - 5) / 5;
            LastCount.SelectedIndexChanged += new System.EventHandler(LastCount_SelectedIndexChanged);
            LastCount_SelectedIndexChanged(null, null);

            if (null != participatedThreads)
            {
                ThreadCollection participatedInThreads = Threads.GetThreadsUserMostRecentlyParticipatedIn(ForumUser.Username, LC);

                if (participatedInThreads.Count > 0)
                {
                    participatedThreads.DataSource = participatedInThreads;
                    participatedThreads.DataBind();
                }
                else
                {
                    participatedThreads.Visible = false;
                    Label label = (Label)skin.FindControl("NoParticipatedThreads");
                    if (null != label)
                    {
                        label.Visible = true;
                    }
                }
            }
        }
コード例 #6
0
        public void FindControl()
        {
            // Type
            var @this = new Control();
            @this.Controls.Add(new Literal {ID = "Fizz"});

            // Examples
            var value1 = @this.FindControl<Literal>("Fizz"); // return control as Literal.
            var value2 = @this.FindControl<Literal>("Buzz"); // return null;
        }
コード例 #7
0
    public System.Web.UI.Control FindControlEx(System.Web.UI.Control Parent, string ID)
    {
        System.Web.UI.Control oCtrl = null;

        //先使用 FindControl 去尋找指定的子控制項

        oCtrl = Parent.FindControl(ID);



        //若尋找不到則往下層遞迴方式去尋找()
        if (oCtrl == null)
        {
            foreach (System.Web.UI.Control oChildCtrl in Parent.Controls)
            {
                oCtrl = FindControlEx(oChildCtrl, ID);
                if (oCtrl != null)
                {
                    break;
                }
            }
        }


        return(oCtrl);
    }
コード例 #8
0
        internal static Control FindTargetControl(string controlID, Control control, bool searchNamingContainers) {
            Control foundControl;
            if (searchNamingContainers) {
                Control currentContainer;
                foundControl = null;

                // DevDiv 73305: Do not assume starting control is not a naming container.
                if (control is INamingContainer) {
                    currentContainer = control;
                }
                else {
                    currentContainer = control.NamingContainer;
                }

                do {
                    foundControl = currentContainer.FindControl(controlID);
                    currentContainer = currentContainer.NamingContainer;
                }
                while (foundControl == null && currentContainer != null);
            }
            else {
                foundControl = control.FindControl(controlID);
            }

            return foundControl;
        }
コード例 #9
0
        /// <summary>
        /// ��ʵ�嵽�ؼ�
        /// </summary>
        /// <param name="entity">ʵ��</param>
        /// <param name="container">�ؼ�</param>
        public static void BindObjectToControls(object entity, Control container)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            if (entity == null) return;

            Type type = entity.GetType();
            PropertyInfo[] propertiesArray = type.GetProperties();

            foreach (PropertyInfo property in propertiesArray)
            {
                Control control = container.FindControl(property.Name);
                if (control == null) continue;

                if (control is ListControl)
                {
                    SetListControl(entity, property, control);
                }
                else
                {
                    SetGeneralControl(entity, property, control);
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// �󶨿ؼ���ʵ��
        /// </summary>
        /// <param name="entity">ʵ��</param>
        /// <param name="container">�ؼ�</param>
        public static void BindControlsToObject(object entity, Control container)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            if (entity == null) return;

            Type objType = entity.GetType();
            PropertyInfo[] objPropertiesArray = objType.GetProperties();

            foreach (PropertyInfo objProperty in objPropertiesArray)
            {
                Control control = container.FindControl(objProperty.Name.ToLower(CultureInfo.InvariantCulture));
                if (control == null) continue;
                if (control is ListControl)
                {
                    SetListObject(entity, objProperty, control);
                }
                else
                {
                    SetGeneralObject(entity, objProperty, control);
                }
            }
        }
コード例 #11
0
ファイル: ControlBase.cs プロジェクト: Novthirteen/yfkey-scms
        /// <summary>
        /// This helper automates locating a control by ID.
        ///
        /// It calls FindControl on the NamingContainer, then the Page.  If that fails,
        /// it fires the resolve event.
        /// </summary>
        /// <param name="id">The ID of the control to find</param>
        /// <param name="props">The TargetProperties class associated with that control</param>
        /// <returns></returns>
        protected System.Web.UI.Control FindControlHelper(string id)
        {
            System.Web.UI.Control c = null;
            if (_findControlHelperCache.ContainsKey(id))
            {
                c = _findControlHelperCache[id];
            }
            else
            {
                c = base.FindControl(id);  // Use "base." to avoid calling self in an infinite loop
                System.Web.UI.Control nc = NamingContainer;
                while ((null == c) && (null != nc))
                {
                    c  = nc.FindControl(id);
                    nc = nc.NamingContainer;
                }
                //if (null == c)
                //{
                //    // Note: props MAY be null, but we're firing the event anyway to let the user
                //    // do the best they can
                //    ResolveControlEventArgs args = new ResolveControlEventArgs(id);

                //    OnResolveControlID(args);
                //    c = args.Control;

                //}
                if (null != c)
                {
                    _findControlHelperCache[id] = c;
                }
            }
            return(c);
        }
コード例 #12
0
        public override bool UpdateItem(ContentItem item, Control editor)
        {
            var textBox = (TextBox)editor.FindControl(Name);
            item[Name] = textBox.Text;

            return true;
        }
コード例 #13
0
ファイル: Globals.cs プロジェクト: huayang912/cs-dotnetnuke
 public static Control FindControlRecursive( Control objParent, string strControlName, string strClientID )
 {
     Control control = objParent.FindControl( strControlName );
     if( control != null )
     {
         return control;
     }
     foreach( Control parent in objParent.Controls )
     {
         if( parent.HasControls() )
         {
             control = FindControlRecursive( parent, strControlName, strClientID );
         }
         // HACK : Modified to not error if object is null.
         //if( ( ( control != null ) && ( strClientID.Length > 0 ) ) && ( String.Compare( control.ClientID, strClientID, false ) != 0 ) )
         if (((control != null) && (!String.IsNullOrEmpty(strClientID))) && (String.Compare(control.ClientID, strClientID, false) != 0))
         {
             control = null;
         }
         if( control != null )
         {
             return control;
         }
     }
     return control;
 }
コード例 #14
0
        protected void CheckAllModificaCampi_CheckedChanged(object sender, EventArgs e)
        {
            if (dg_Campi != null && dg_Campi.Items.Count > 0)
            {
                System.Web.UI.Control Header = dg_Campi.Controls[0].Controls[0];
                ((CheckBox)Header.FindControl("CheckAllVisibilitaCampi")).Checked = true;

                if (((System.Web.UI.WebControls.CheckBox)sender).Checked)
                {
                    for (int i = 0; i < dg_Campi.Items.Count; i++)
                    {
                        ((CheckBox)dg_Campi.Items[i].Cells[2].Controls[1]).Checked = true;
                        ((CheckBox)dg_Campi.Items[i].Cells[3].Controls[1]).Checked = true;
                        ((CheckBox)dg_Campi.Items[i].Cells[3].Controls[1]).Enabled = false;
                    }
                }
                if (!((System.Web.UI.WebControls.CheckBox)sender).Checked)
                {
                    for (int i = 0; i < dg_Campi.Items.Count; i++)
                    {
                        ((CheckBox)dg_Campi.Items[i].Cells[2].Controls[1]).Checked = false;
                        ((CheckBox)dg_Campi.Items[i].Cells[3].Controls[1]).Enabled = true;
                    }
                }
            }
        }
コード例 #15
0
 protected void AddTitleAttribute(Control container, string checkBoxName)
 {
     CheckBox cb = (CheckBox)container.FindControl(checkBoxName);
     if (cb != null) {
         cb.InputAttributes.Add("title", (string)GetGlobalResourceObject("GlobalResources", "AutoPostBackCheckBoxWarning"));
     }
 }
コード例 #16
0
        protected void CheckAllCreazioneTipologia_CheckedChanged(object sender, EventArgs e)
        {
            if (dg_Ruoli != null && dg_Ruoli.Items.Count > 0)
            {
                System.Web.UI.Control Header = dg_Ruoli.Controls[0].Controls[0];
                ((CheckBox)Header.FindControl("CheckAllRicercaTipologia")).Checked = true;

                if (((System.Web.UI.WebControls.CheckBox)sender).Checked)
                {
                    for (int i = 0; i < dg_Ruoli.Items.Count; i++)
                    {
                        ((CheckBox)dg_Ruoli.Items[i].Cells[3].Controls[1]).Checked = true;
                        ((CheckBox)dg_Ruoli.Items[i].Cells[4].Controls[1]).Checked = true;
                        ((CheckBox)dg_Ruoli.Items[i].Cells[4].Controls[1]).Enabled = false;

                        //((CheckBox)dg_Ruoli.Items[i].Cells[2].Controls[1]).Checked = true;
                        //((CheckBox)dg_Ruoli.Items[i].Cells[3].Controls[1]).Checked = true;
                        //((CheckBox)dg_Ruoli.Items[i].Cells[3].Controls[1]).Enabled = false;
                    }
                }
                if (!((System.Web.UI.WebControls.CheckBox)sender).Checked)
                {
                    for (int i = 0; i < dg_Ruoli.Items.Count; i++)
                    {
                        ((CheckBox)dg_Ruoli.Items[i].Cells[3].Controls[1]).Checked = false;
                        ((CheckBox)dg_Ruoli.Items[i].Cells[4].Controls[1]).Enabled = true;

                        //((CheckBox)dg_Ruoli.Items[i].Cells[2].Controls[1]).Checked = false;
                        //((CheckBox)dg_Ruoli.Items[i].Cells[3].Controls[1]).Enabled = true;
                    }
                }
            }
        }
コード例 #17
0
ファイル: BaseControl.cs プロジェクト: zi-yu/orionsbelt
 /// <summary>
 /// mtodo para obter o control que existe na skin que estamos
 /// a carregar
 /// </summary>
 /// <param name="skin">a skin corrente</param>
 /// <param name="controlName">nome do control a procurar</param>
 /// <returns>o control que est associado ao nome</returns>
 public Control getControl(Control skin, string controlName)
 {
     Control ctrl = skin.FindControl(controlName);
     if (ctrl == null)
         throw new AlnitakException( "Nao foi possivel encontrar o controlo "+ controlName +" na skin "+ skin.ToString() );
     return ctrl;
 }
 private void ExtractTemplateValuesRecursive(ArrayList subBuilders, OrderedDictionary table, Control container)
 {
     foreach (object obj2 in subBuilders)
     {
         ControlBuilder builder = obj2 as ControlBuilder;
         if (builder != null)
         {
             ICollection boundPropertyEntries;
             if (!builder.HasFilteredBoundEntries)
             {
                 boundPropertyEntries = builder.BoundPropertyEntries;
             }
             else
             {
                 ServiceContainer serviceProvider = new ServiceContainer();
                 serviceProvider.AddService(typeof(IFilterResolutionService), builder.TemplateControl);
                 try
                 {
                     builder.SetServiceProvider(serviceProvider);
                     boundPropertyEntries = builder.GetFilteredPropertyEntrySet(builder.BoundPropertyEntries);
                 }
                 finally
                 {
                     builder.SetServiceProvider(null);
                 }
             }
             string strA = null;
             bool flag = true;
             Control o = null;
             foreach (BoundPropertyEntry entry in boundPropertyEntries)
             {
                 if (entry.TwoWayBound)
                 {
                     string str2;
                     if (string.Compare(strA, entry.ControlID, StringComparison.Ordinal) != 0)
                     {
                         flag = true;
                     }
                     else
                     {
                         flag = false;
                     }
                     strA = entry.ControlID;
                     if (flag)
                     {
                         o = container.FindControl(entry.ControlID);
                         if ((o == null) || !entry.ControlType.IsInstanceOfType(o))
                         {
                             continue;
                         }
                     }
                     object target = PropertyMapper.LocatePropertyObject(o, entry.Name, out str2, base.InDesigner);
                     table[entry.FieldName] = FastPropertyAccessor.GetProperty(target, str2, base.InDesigner);
                 }
             }
             this.ExtractTemplateValuesRecursive(builder.SubBuilders, table, container);
         }
     }
 }
コード例 #19
0
        public override bool UpdateItem(ContentItem item, Control editor)
        {
            ContentItem questionItem = Utility.GetProperty(item, Name) as ContentItem;

            CheckBox cb = editor.FindControl(GetCheckBoxName()) as CheckBox;
            if (cb.Checked || questionItem == null)
            {
                questionItem = new SingleSelect();
                questionItem.AddTo(item);
                Utility.UpdateSortOrder(item.Children);
            }

            TextBox tb = editor.FindControl(GetTextBoxName()) as TextBox;
            questionItem.Title = tb.Text;

            return base.UpdateItem(questionItem, editor);
        }
コード例 #20
0
ファイル: ShowPlanets.cs プロジェクト: zi-yu/orionsbelt
        /// <summary>Preenche os controlos relativos a um recurso</summary>
        private void fillResourceType( string resource, Control control, Chronos.Core.Planet planet)
        {
            QueueItem item = planet.current(resource);

            Label type = (Label) control.FindControl("resource" + resource);
            if( type != null ) {
                if( item != null ) {
                    type.EnableViewState = false;
                    if( item == null ) {
                        type.Text = "-";
                    } else {
                        string resType = info.getContent(item.FactoryName);
                        type.Text = resType;
                    }
                } else {
                    type.Text = "-";
                }
            }

            Label queueCount = (Label) control.FindControl("queueCount" + resource);
            if( queueCount != null ) {
                queueCount.EnableViewState = false;
                queueCount.Text = planet.queueCount(resource).ToString();
            }

            Label quantity = (Label) control.FindControl("quantity" + resource);
            if( quantity != null ) {
                if( item != null ) {
                    quantity.EnableViewState = false;
                    quantity.Text = item.Quantity.ToString();
                } else {
                    quantity.Text = "-";
                }
            }

            Label toGo = (Label) control.FindControl("toGo" + resource);
            if( toGo != null ) {
                if( item != null ) {
                    toGo.EnableViewState = false;
                    toGo.Text = "+ " + item.RemainingTurns;
                } else {
                    toGo.Text = "-";
                }
            }
        }
コード例 #21
0
ファイル: ShowPlanet.cs プロジェクト: zi-yu/orionsbelt
 /// <summary>Preenche um Panel</summary>
 private void fillPanel( Control container, string label, int val )
 {
     Panel panel = (Panel) container.FindControl(label);
     if( panel != null ) {
         panel.EnableViewState = false;
         panel.Width = new Unit(val, UnitType.Percentage);
         panel.Controls.Add( new LiteralControl(val.ToString() + "%") );
     }
 }
コード例 #22
0
ファイル: ShowPlanet.cs プロジェクト: zi-yu/orionsbelt
        /// <summary>Inicializa uma Label</summary>
        private void fillLabel( Control container, string label, string text )
        {
            Label control = (Label) container.FindControl(label);

            if( control != null ) {
                control.EnableViewState = false;
                control.Text = text;
            }
        }
コード例 #23
0
    public override void SaveValidatorSettings(Control parentCtrl)
    {
      this.Data.Properties.Clear();

      TextBox expressionBox = (TextBox)parentCtrl.FindControl("_expression");
      if (expressionBox != null)
      {
        this.Data.Properties["Regex"] = HttpContext.Current.Server.HtmlEncode(expressionBox.Text);
      }
    }
コード例 #24
0
        private string GetTextFromInnerControl(Control control, string innerControlID)
        {
            TextBox field = control.FindControl(innerControlID) as TextBox;
            if (field == null)
            {
                return null;
            }

            return field.Text.Trim();
        }
コード例 #25
0
        public override void UpdateEditor(ContentItem item, Control editor)
        {
            ContentItem questionItem = Utility.GetProperty(item, Name) as ContentItem
                                       ?? new SingleSelect();

            TextBox tb = editor.FindControl(GetTextBoxName()) as TextBox;
            tb.Text = questionItem.Title;

            base.UpdateEditor(questionItem, editor);
        }
コード例 #26
0
ファイル: ViewHelper.cs プロジェクト: Mariamfelicia/nreco
 public static void SetControlValue(Control container, string ctrlId, object val)
 {
     var ctrl = container.FindControl(ctrlId);
     if (ctrl==null) return;
     if (ctrl is ITextControl)
         ((ITextControl)ctrl).Text = Convert.ToString(val);
     if (ctrl is ICheckBoxControl)
         ((ICheckBoxControl)ctrl).Checked = ConvertManager.ChangeType<bool>(val);
     if (ctrl is IDateBoxControl)
         ((IDateBoxControl)ctrl).Date = AssertHelper.IsFuzzyEmpty(val) ? null : (DateTime?)ConvertManager.ChangeType<DateTime>(val);
 }
コード例 #27
0
ファイル: TabContainerDesigner.cs プロジェクト: syurov/rt.srz
        /// <summary>
        /// Helper to get a unique name.  Since our Tabs aren't onthe designer surface,
        /// INamingSurface won't do the right thing.  Fortunately, it's easy.
        /// </summary>
        /// <returns>A unique name like "TabPanel3"</returns>
        private static string GetUniqueName(Type t, System.Web.UI.Control parent)
        {
            string baseName = t.Name;
            int    count    = 1;

            while (parent.FindControl(baseName + count.ToString(CultureInfo.InvariantCulture)) != null)
            {
                count++;
            }
            return(baseName + count.ToString(CultureInfo.InvariantCulture));
        }
コード例 #28
0
ファイル: Common.cs プロジェクト: arbh89/DropDownListChosen
 public static Control FindControlReqursive(string controlId, Control parent)
 {
     foreach (Control control in parent.Controls)
     {
         Control result = FindControlReqursive(controlId, control);
         if (result != null)
         {
             return result;
         }
     }
     return parent.FindControl(controlId);
 }
コード例 #29
0
        private static int? GetJobGroupId(Control row)
        {
            var jobGroupIdHiddenField = (HiddenField)row.FindControl("JobGroupIdHiddenField");

            int jobGroupId;
            if (jobGroupIdHiddenField != null && int.TryParse(jobGroupIdHiddenField.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out jobGroupId))
            {
                return jobGroupId;
            }

            return null;
        }
コード例 #30
0
        /// <summary>Gets the ID of the status represented in the given row.</summary>
        /// <param name="row">The row representing a status.</param>
        /// <returns>The ID of the status represented in the given row</returns>
        private static int? GetStatusId(Control row)
        {
            var statusIdHiddenField = (HiddenField)row.FindControl("StatusIdHiddenField");

            int statusId;
            if (statusIdHiddenField != null && int.TryParse(statusIdHiddenField.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out statusId))
            {
                return statusId;
            }

            return null;
        }
コード例 #31
0
 public System.Collections.Specialized.IOrderedDictionary @__ExtractValues__control26(System.Web.UI.Control @__container)
 {
     System.Collections.Specialized.OrderedDictionary @__table;
     System.Web.UI.WebControls.Label Label1;
     Label1   = ((System.Web.UI.WebControls.Label)(@__container.FindControl("Label1")));
     @__table = new System.Collections.Specialized.OrderedDictionary();
     if ((Label1 != null))
     {
         @__table["Status"] = Label1.Text;
     }
     return(@__table);
 }
コード例 #32
0
ファイル: ControlUtil.cs プロジェクト: porter1130/C-A
        public static Control FindChildControl(Control ctl, string id)
        {
            Control target = ctl.FindControl(id);

            if (target != null) return target;
            foreach (Control c in ctl.Controls)
            {
                target = FindChildControl(c, id);
                if (target != null) return target;
            }
            return target;
        }
コード例 #33
0
        /// <summary>Preenche os controlos relativos a um recurso</summary>
        private void fillResource( string resource, Control control, Chronos.Core.Planet planet)
        {
            Label quantity = (Label) control.FindControl(resource + "Quantity");
            if( quantity != null ) {
                quantity.EnableViewState = false;
                int val = planet.getResourceCount(resource);
                quantity.Text = val.ToString();
                if( val < 0 ) {
                    quantity.CssClass = "error";
                }
            }

            Label ratio = (Label) control.FindControl(resource + "Ratio");
            if( ratio != null ) {
                ratio.EnableViewState = false;
                int val = planet.getRatio(resource);
                if( val > 0 ) {
                    ratio.Text = val.ToString() + "%";
                } else {
                    ratio.Text = "-";
                }
            }

            Label perTurn = (Label) control.FindControl(resource + "PerTurn");
            if( perTurn != null ) {
                perTurn.EnableViewState = false;
                int val = planet.getPerTurn("Intrinsic",resource);
                string str = val.ToString();

                if( val > 0 ) {
                    str = "+" + str;
                    perTurn.Text = str;
                } else if( val == 0 ) {
                    perTurn.Text = "-";
                } else {
                    perTurn.CssClass = "error";
                    perTurn.Text = str;
                }
            }
        }
コード例 #34
0
ファイル: BulkEditGridViewEx.cs プロジェクト: bneuhold/pb-dev
 protected Control RecursiveFindControl(Control namingcontainer, string controlName)
 {
     Control control = namingcontainer.FindControl(controlName);
     if (control != null)
     {
         return control;
     }
     if (namingcontainer.NamingContainer != null)
     {
         return this.RecursiveFindControl(namingcontainer.NamingContainer, controlName);
     }
     return null;
 }
コード例 #35
0
ファイル: Web.cs プロジェクト: rprudnikov-itrf/rosbuh
        public static void СохранитьЗначение(decimal id_node, string[] attributes, Хранилище хранилище, System.Web.UI.Control content)
        {
            using (RosService.Client client = new RosService.Client())
            {
                var values = new Dictionary <string, object>();
                foreach (var item in client.Архив.ПолучитьЗначение(id_node, attributes))
                {
                    var control = content.FindControl(Regex.Replace(item.Key.ToString(), "[./]", "_"));
                    if (control == null)
                    {
                        continue;
                    }

                    if (control is ListControl)
                    {
                        if (Convert.ToString(item.Value) != (control as ListControl).SelectedValue)
                        {
                            values.Add(item.Key, (control as ListControl).SelectedValue);
                        }
                    }
                    else if (control is ITextControl)
                    {
                        if (control is TextBox && ((TextBox)control).ReadOnly)
                        {
                            continue;
                        }
                        if (Convert.ToString(item.Value) != (control as ITextControl).Text)
                        {
                            values.Add(item.Key, (control as ITextControl).Text);
                        }
                    }
                    else if (control is System.Web.UI.WebControls.Repeater)
                    {
                        if ((control as System.Web.UI.WebControls.Repeater).DataSource is DataTable ||
                            (control as System.Web.UI.WebControls.Repeater).DataSource is DataView)
                        {
                            (control as System.Web.UI.WebControls.Repeater).DataSource = item.Value;
                        }
                    }
                    else if (control is System.Web.UI.WebControls.BaseDataList)
                    {
                        if ((control as System.Web.UI.WebControls.BaseDataList).DataSource is DataTable ||
                            (control as System.Web.UI.WebControls.BaseDataList).DataSource is DataView)
                        {
                            (control as System.Web.UI.WebControls.BaseDataList).DataSource = item.Value;
                        }
                    }
                }
                client.Архив.СохранитьЗначение(id_node, values, хранилище);
            }
        }
コード例 #36
0
ファイル: PageDo.cs プロジェクト: SoMeTech/SoMeRegulatory
 public static void IsChanged(ref bool yn, ref string strEditMess, Control parcontrol, Control control, bool IsSaveTitle, Page page)
 {
     if ((control.ID != null) && (control.ID.IndexOf("_bak") > 0))
     {
         string text = "";
         if (IsSaveTitle)
         {
             string str2 = "lab" + control.ID.Remove(0, 3);
             Label label = (Label) parcontrol.FindControl(str2.Replace("_bak", ""));
             if (label != null)
             {
                 text = label.Text;
             }
         }
         if (control is TextBox)
         {
             TextBox box = (TextBox) parcontrol.FindControl(control.ID.Replace("_bak", ""));
             TextBox box2 = (TextBox) control;
             if (((box != null) && (box2 != null)) && (box.Text != box2.Text))
             {
                 string str3 = strEditMess;
                 strEditMess = str3 + text + " 从 " + box2.Text + " 改为 " + box.Text + " ~ ";
                 yn = true;
             }
         }
         if (control is HtmlInputHidden)
         {
             HtmlInputHidden hidden = (HtmlInputHidden) parcontrol.FindControl(control.ID.Replace("_bak", ""));
             HtmlInputHidden hidden2 = (HtmlInputHidden) control;
             if (((hidden != null) && (hidden2 != null)) && (hidden.Value != hidden2.Value))
             {
                 string str4 = strEditMess;
                 strEditMess = str4 + text + " 从 " + hidden2.Value + " 改为 " + hidden.Value + " ~ ";
                 yn = true;
             }
         }
     }
 }
コード例 #37
0
        /// <summary>
        /// Finds the specified child control and casts it to the specified type, or returns a NULL value if a control that the specified type is not found.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="ctrl"></param>
        /// <param name="controlID"></param>
        /// <returns></returns>
        public static T FindControl <T>(this System.Web.UI.Control ctrl, string controlID, bool throwExceptionIfNull = true)
            where T : System.Web.UI.Control
        {
            var childCtrl = (ctrl.FindControl(controlID) as T);

            if (childCtrl == null && throwExceptionIfNull)
            {
                throw new ControlNotFoundException(controlID, ctrl);
            }
            else
            {
                return(childCtrl);
            }
        }
コード例 #38
0
        private Control FindControl(Control toSearch, string idToFind)
        {
            Control c = toSearch.FindControl(idToFind);
            if (c == null && toSearch.Controls != null)
            {
                foreach (Control subControl in toSearch.Controls)
                {
                    c = FindControl(subControl, idToFind);
                    if (c != null) break;
                }
            }

            return c;
        }
コード例 #39
0
ファイル: Common.cs プロジェクト: Rtluats/CurseWork
        public static T FindControl <T>(this System.Web.UI.Control parent, string controlId) where T : System.Web.UI.Control
        {
            var control = parent.FindControl(controlId);

            if (control == null)
            {
                return(null);
            }
            if (control is T)
            {
                return((T)control);
            }
            throw new Exception("The control with the ID of '" + controlId + "' is of type " + control.GetType().FullName + ". It cannot be casted to type " +
                                typeof(T).FullName + ".");
        }
コード例 #40
0
 System.Web.UI.Control FindTemplateControl(System.Web.UI.Control RootControl, string id)
 {
     System.Web.UI.Control foundedControl = RootControl.FindControl(id);
     if (foundedControl == null)
     {
         foreach (System.Web.UI.Control item in RootControl.Controls)
         {
             foundedControl = FindTemplateControl(item, id);
             if (foundedControl != null)
             {
                 break;
             }
         }
     }
     return(foundedControl);
 }
コード例 #41
0
    protected void GenerateOpensocialJavascipt()
    {
        System.Web.UI.Control pnlOpenSocialScripts = Master.Master.FindControl("HeadContentPlaceHolder").FindControl("pnlOpenSocialScripts");
        pnlOpenSocialScripts.Visible = osHelper.IsVisible();
        if (osHelper.IsVisible())
        {
            string gadgetScriptText = "<script type=\"text/javascript\" src=\"" + osHelper.GetContainerJavascriptSrc() + "\"></script>" + Environment.NewLine +
                                      "<script type=\"text/javascript\" language=\"javascript\">" + Environment.NewLine +
                                      "var my = {};" + Environment.NewLine +
                                      "my.gadgetSpec = function(appId, name, url, secureToken, view, closed_width, open_width, start_closed, chrome_id, visible_scope) {" + Environment.NewLine +
                                      "this.appId = appId;" + Environment.NewLine +
                                      "this.name = name;" + Environment.NewLine +
                                      "this.url = url;" + Environment.NewLine +
                                      "this.secureToken = secureToken;" + Environment.NewLine +
                                      "this.view = view || 'default';" + Environment.NewLine +
                                      "this.closed_width = closed_width;" + Environment.NewLine +
                                      "this.open_width = open_width;" + Environment.NewLine +
                                      "this.start_closed = start_closed;" + Environment.NewLine +
                                      "this.chrome_id = chrome_id;" + Environment.NewLine +
                                      "this.visible_scope = visible_scope;" + Environment.NewLine +
                                      "};" + Environment.NewLine +
                                      "my.pubsubData = {};" + Environment.NewLine;
            foreach (KeyValuePair <string, string> pair in osHelper.GetPubsubData())
            {
                gadgetScriptText += "my.pubsubData['" + pair.Key + "'] = '" + pair.Value + "';" + Environment.NewLine;
            }
            gadgetScriptText += "my.openSocialURL = '" + ConfigUtil.GetConfigItem("OpenSocialURL") + "';" + Environment.NewLine +
                                "my.debug = " + (osHelper.IsDebug() ? "1" : "0") + ";" + Environment.NewLine +
                                "my.noCache = " + (osHelper.NoCache() ? "1" : "0") + ";" + Environment.NewLine +
                                "my.gadgets = [";
            foreach (PreparedGadget gadget in osHelper.GetVisibleGadgets())
            {
                gadgetScriptText += "new my.gadgetSpec(" + gadget.GetAppId() + ",'" + gadget.GetName() + "','" + gadget.GetGadgetURL() + "','" +
                                    gadget.GetSecurityToken() + "','" + gadget.GetView() + "'," + gadget.GetClosedWidth() + "," +
                                    gadget.GetOpenWidth() + "," + (gadget.GetStartClosed() ? "1" : "0") + ",'" + gadget.GetChromeId() + "','" +
                                    gadget.GetGadgetSpec().GetVisibleScope() + "'), ";
            }
            gadgetScriptText = gadgetScriptText.Substring(0, gadgetScriptText.Length - 2) + "];" + Environment.NewLine + "</script>" + Environment.NewLine +
                               "<script type=\"text/javascript\" src=\"Scripts/profilesShindig.js\"></script>";

            ((System.Web.UI.WebControls.Literal)pnlOpenSocialScripts.FindControl("GadgetJavascriptLiteral")).Text = gadgetScriptText;

            // tools
            System.Web.UI.Control pnlOpenSocialTools = Master.Master.FindControl("left").FindControl("pnlOpenSocialTools");
            pnlOpenSocialTools.Visible = osHelper.IsVisible();
        }
    }
コード例 #42
0
ファイル: FormHelper.cs プロジェクト: Prolliance/Membership
        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]);
                    }
                }
            }
        }
コード例 #43
0
        protected void DelSection_Click()
        {
            string source = Context.ClientPage.ClientRequest.Source;

            if (!string.IsNullOrEmpty(source) && (source.Length > "DelSection".Length))
            {
                string str2 = source.Substring("DelSection".Length);
                if (this.FieldsSection.Controls.Count >= 1)
                {
                    System.Web.UI.Control control = this.FieldsSection.Controls[0];
                    foreach (string str3 in new string[] { "Field", "Property", "DelSection" })
                    {
                        System.Web.UI.Control control2 = control.FindControl(str3 + str2);
                        if (control2 != null)
                        {
                            control.Controls.Remove(control2);
                        }
                    }
                    SheerResponse.Refresh(this.FieldsSection);
                }
            }
        }
コード例 #44
0
        protected void shoppingCartProductList_ItemCommand(object sender, System.Web.UI.WebControls.DataListCommandEventArgs e)
        {
            System.Web.UI.Control             control = e.Item.Controls[0];
            System.Web.UI.WebControls.TextBox textBox = (System.Web.UI.WebControls.TextBox)control.FindControl("txtBuyNum");
            System.Web.UI.WebControls.Literal literal = (System.Web.UI.WebControls.Literal)control.FindControl("litSkuId");
            int num;

            if (!int.TryParse(textBox.Text, out num) || textBox.Text.IndexOf(".") != -1)
            {
                this.ShowMessage("购买数量必须为整数", false);
            }
            else
            {
                if (num <= 0)
                {
                    this.ShowMessage("购买数量必须为大于0的整数", false);
                }
                else
                {
                    if (e.CommandName == "updateBuyNum")
                    {
                        if (ShoppingCartProcessor.GetSkuStock(literal.Text.Trim()) < num)
                        {
                            this.ShowMessage("该商品库存不够", false);
                            return;
                        }
                        ShoppingCartProcessor.UpdateLineItemQuantity(literal.Text, num);
                    }
                    if (e.CommandName == "delete")
                    {
                        ShoppingCartProcessor.RemoveLineItem(literal.Text);
                    }
                    this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("shoppingCart"), true);
                }
            }
        }
コード例 #45
0
ファイル: UserPoints.cs プロジェクト: damoOnly/e-commerce
 protected void pointList_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item || e.Item.ItemType == System.Web.UI.WebControls.ListItemType.AlternatingItem)
     {
         System.Web.UI.Control           control = e.Item.Controls[0];
         System.Web.UI.WebControls.Label label   = (System.Web.UI.WebControls.Label)control.FindControl("lblPointType");
         if (label != null)
         {
             if (label.Text == "0")
             {
                 label.Text = "兑换优惠券";
                 return;
             }
             if (label.Text == "1")
             {
                 label.Text = "兑换礼品";
                 return;
             }
             if (label.Text == "2")
             {
                 label.Text = "购物奖励";
                 return;
             }
             if (label.Text == "3")
             {
                 label.Text = "退款扣积分";
             }
         }
     }
 }
コード例 #46
0
        protected void shoppingCartGiftList_ItemCommand(object sender, System.Web.UI.WebControls.DataListCommandEventArgs e)
        {
            System.Web.UI.Control             control = e.Item.Controls[0];
            System.Web.UI.WebControls.TextBox textBox = (System.Web.UI.WebControls.TextBox)control.FindControl("txtBuyNum");
            System.Web.UI.WebControls.Literal literal = (System.Web.UI.WebControls.Literal)control.FindControl("litGiftId");
            int num;

            if (!int.TryParse(textBox.Text, out num) || textBox.Text.IndexOf(".") != -1)
            {
                this.ShowMessage("兑换数量必须为整数", false);
            }
            else
            {
                if (num <= 0)
                {
                    this.ShowMessage("兑换数量必须为大于0的整数", false);
                }
                else
                {
                    if (e.CommandName == "updateBuyNum")
                    {
                        ShoppingCartProcessor.UpdateGiftItemQuantity(System.Convert.ToInt32(literal.Text), num, PromoteType.NotSet);
                    }
                    if (e.CommandName == "delete")
                    {
                        ShoppingCartProcessor.RemoveGiftItem(System.Convert.ToInt32(literal.Text), PromoteType.NotSet);
                    }
                    this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("shoppingCart"), true);
                }
            }
        }
コード例 #47
0
ファイル: FormHelper.cs プロジェクト: Prolliance/Membership
 /// <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
     }
 }
コード例 #48
0
ファイル: FormHelper.cs プロジェクト: Prolliance/Membership
        /// <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
            }
        }
コード例 #49
0
    protected void ListView3_ItemInserting(object sender, ListViewInsertEventArgs e)
    {
        ListView lv = (ListView)sender;

        System.Web.UI.Control lvi = (System.Web.UI.Control)lv.Parent;
        //Panel lvii = (Panel)lvi.Parent;
        string post_userId = ((Label)lvi.FindControl("UserIdLabel")).Text;

        postKey = new Guid(((Label)lvi.FindControl("PhotoIDLabel")).Text);



        //   Guid postKey3 = (Guid)lvi.DataKeys[e.Item.DataItemIndex].Values[0];
        //string   post_userId = ( ((Label)ListView2.FindControl("UserIdLabel")).Text);


        TextBox txtb = (e.Item.FindControl("CommentTextBox")) as TextBox;


        string connectionString = ConfigurationManager.ConnectionStrings["SecurityConnectionString"].ConnectionString;
        string insertSql        = "INSERT INTO PhotoComments(Comment, PhotoID, CommentUser, CommentUserId,CommentUserName) VALUES(@Comment, @PhotoID, @CommentUser, @CommentUserId,@CommentUserName)";

        using (SqlConnection myConnection = new SqlConnection(connectionString))
        {
            myConnection.Open();
            SqlCommand myCommand = new SqlCommand(insertSql, myConnection);
            myCommand.Parameters.AddWithValue("@Comment", txtb.Text.Trim());
            myCommand.Parameters.AddWithValue("@PhotoID", postKey);


            myCommand.Parameters.AddWithValue("@CommentUserName", User.Identity.Name);
            myCommand.Parameters.AddWithValue("@CommentUser", HttpContext.Current.Session["user"]);
            myCommand.Parameters.AddWithValue("@CommentUserId", currentUserId);



            myCommand.ExecuteNonQuery();
            myConnection.Close();
        }
        try
        {
            if (currentUserId.ToString() != post_userId)
            {
                string connectionString12 =
                    ConfigurationManager.ConnectionStrings["SecurityConnectionString"].ConnectionString;


                string insertSql2 = "INSERT INTO Notifications(UserId,Type,NotifyTo,PostId) VALUES(@UserId,@Type,@NotifyTo,@PostId)";

                using (SqlConnection myConnection = new SqlConnection(connectionString12))
                {
                    myConnection.Open();
                    SqlCommand myCommand = new SqlCommand(insertSql2, myConnection);

                    myCommand.Parameters.AddWithValue("@Type", "Post_Comment");
                    myCommand.Parameters.AddWithValue("@UserId", currentUserId);
                    myCommand.Parameters.AddWithValue("@NotifyTo", post_userId);
                    myCommand.Parameters.AddWithValue("@PostId", postKey);
                    myCommand.ExecuteNonQuery();
                    myConnection.Close();
                }
            }
        }
        catch { }

        e.Cancel = true;
        //MediaDS.SelectCommand = "SELECT * FROM [PhotoComments] WHERE ([PhotoID] = '" + postKey + "') ORDER BY [CommentDate]";


        //MediaDS.DataBind();
        lv.DataBind();

        UpdatePanel upl = lvi.FindControl("UpdatePanel2") as UpdatePanel;

        upl.Update();
    }
コード例 #50
0
ファイル: Web.cs プロジェクト: rprudnikov-itrf/rosbuh
        /// <summary>
        /// Загузить значения в html каротчку
        /// </summary>
        public static void ПолучитьЗначение(decimal id_node, string[] attributes, Хранилище хранилище, System.Web.UI.Control content)
        {
            using (RosService.Client client = new RosService.Client())
            {
                foreach (var item in client.Архив.ПолучитьЗначение(id_node, attributes, хранилище))
                {
                    var control = content.FindControl(Regex.Replace(item.Key.ToString(), "[./]", "_"));
                    if (control == null)
                    {
                        continue;
                    }


                    if (control is System.Web.UI.WebControls.ListControl)
                    {
                        var items = control as System.Web.UI.WebControls.ListControl;
                        if (items.DataSource != null && items.Items.Count == 0)
                        {
                            items.DataBind();
                        }

                        var str      = (item.Value is string) ? (string)item.Value : string.Format("{0:f0}", item.Value);
                        var ListItem = items.Items.FindByValue(str);
                        if (ListItem != null)
                        {
                            items.SelectedValue = str;
                        }
                    }
                    else if (control is System.Web.UI.ITextControl)
                    {
                        try
                        {
                            if (item.Value is DateTime)
                            {
                                (control as System.Web.UI.ITextControl).Text = Convert.ToDateTime(item.Value).ToShortDateString();
                            }
                            else if (item.Value is double || item.Value is decimal)
                            {
                                (control as System.Web.UI.ITextControl).Text = Convert.ToDouble(item.Value).ToString("N2");
                            }
                            else
                            {
                                (control as System.Web.UI.ITextControl).Text = item.Value.ToString();
                            }
                        }
                        catch
                        {
                            (control as System.Web.UI.ITextControl).Text = null;
                        }
                    }
                    else if (control is System.Web.UI.WebControls.Repeater)
                    {
                        (control as System.Web.UI.WebControls.Repeater).DataSource = item.Value;
                    }
                    else if (control is System.Web.UI.WebControls.DataList)
                    {
                        (control as System.Web.UI.WebControls.DataList).DataSource = item.Value;
                    }
                }
            }
        }
コード例 #51
0
        public void CaseCareLevelSeveritySaveLink_OnClick(Object sender, EventArgs e)
        {
            // GET REFERENCE TO CURRENT LINK BUTTON WEB CONTROL SAVE LINK FROM SENDER OBJECT

            System.Web.UI.WebControls.LinkButton currentSaveLink = (System.Web.UI.WebControls.LinkButton)sender;

            // GET REFERENCE TO CURRENT WEB CONTROL FROM PARENT OF CURRENT SAVE LINK LINK BUTTON WEB CONTROL

            System.Web.UI.Control currentWebControl = (System.Web.UI.Control)currentSaveLink.Parent;

            // GET REFERENCE TO CURRENT CASE CARE LEVEL SEVERITY CHANGE SELECTION RAD COMBO BOX

            Telerik.Web.UI.RadComboBox currentCaseCareLevelSeverityChangeSelection = (Telerik.Web.UI.RadComboBox)currentWebControl.FindControl("CaseCareLevelSeveritySelection");

            // CREATE REFERENCE TO PARSED SELECTED CARE LEVEL ID

            Int64 parsedselectedCareLevelId;

            // TRY TO PARSE SELECTED VALUE OF CURRENT CASE CARE LEVEL SEVERITY CHANGE SELECTION RAD COMBO BOX AS INT 64

            if (Int64.TryParse(currentCaseCareLevelSeverityChangeSelection.SelectedValue, out parsedselectedCareLevelId))
            {
                // SET SELECTED CARE LEVEL ID AS INT 64 OF SELECTED VALUE OF CURRENT CASE CARE LEVEL SEVERITY CHANGE SELECTION RAD COMBO BOX

                Int64 selectedCareLevelId = Convert.ToInt64(currentCaseCareLevelSeverityChangeSelection.SelectedValue);
            }

            // SET MEMBER CASE CARE PLAN SEVERITY LEVEL

            /* TODO: DAVID: SEVERITY (CARE LEVEL) IS NOT YET A PROPERTY OF MEMEBR CASE CARE PLAN IN CODE OR DATABASE */

            return;
        }