当前位置: 首页>>代码示例>>C#>>正文


C# Page.FindControl方法代码示例

本文整理汇总了C#中System.Web.UI.Page.FindControl方法的典型用法代码示例。如果您正苦于以下问题:C# Page.FindControl方法的具体用法?C# Page.FindControl怎么用?C# Page.FindControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.Page的用法示例。


在下文中一共展示了Page.FindControl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ComputerMove

        private static void ComputerMove()
        {
            Random rand = new Random();
            int positionIndex = rand.Next(0, freePositions.Count);
            Position position = freePositions[positionIndex];
            int row = position.X;
            int col = position.Y;

            if (game[row, col] == '*')
            {
                game[row, col] = computerCharacter;
                freePositions.Remove(position);
                Button btn = new Button();
                Page page = new Page();
                if (HttpContext.Current != null)
                {
                    page = (Page)HttpContext.Current.Handler;
                    btn = (Button)page.FindControl("Btn" + row + col);
                    btn.Text = computerCharacter.ToString();
                }
                if (Win(computerCharacter))
                {
                    Label lbWinner = (Label)page.FindControl("Winner");
                    lbWinner.Text = "You win!";
                    lbWinner.Visible = true;
                    computerScores++;
                    UpdateScores(page);
                    return;
                }
            }
            else
            {
                ComputerMove();
            }
        }
开发者ID:Tsvetomir-Kirchev,项目名称:Telerik-Academy-Exercises,代码行数:35,代码来源:default.aspx.cs

示例2: RenderLabelTest

		public static void RenderLabelTest (Page p)
		{
			Assert.AreEqual (Color.Black,((MyWebControl.Label) p.FindControl ("Label")).BackColor, "Default Theme#1");
			Assert.AreEqual (Color.Red, ((MyWebControl.Label) p.FindControl ("LabelRed")).BackColor, "Red Skin Theme#2");
			Assert.AreEqual (Color.Yellow, ((MyWebControl.Label) p.FindControl ("LabelYellow")).BackColor, "Yellow Skin Theme#3");
			Assert.AreEqual (Color.Black, ((MyWebControl.Label) p.FindControl ("LabelOverride")).BackColor, "Override Skin Theme#4");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:7,代码来源:ThemeTest.cs

示例3: ChangeCss

 /// <summary>
 /// Find The HTML Element Inside The HTML Controls, Inside The User Control, Inside The Page And Change The Css Property Of It.
 /// </summary>
 /// <param name="page">Page</param>
 /// <param name="userControlID">UserControlID</param>
 /// <param name="htmlControlID">HTML ControlID</param>
 /// <param name="elementID">Element ID</param>
 /// <param name="key"> Css Tag</param>
 /// <param name="value">Value</param>
 public void ChangeCss(Page page, string userControlID, string htmlControlID, string elementID, string key, string value)
 {
     PlaceHolder pchWhole = page.FindControl(userControlID) as PlaceHolder;
     UserControl uc = pchWhole.FindControl(htmlControlID) as UserControl;
     HtmlGenericControl div = uc.FindControl(elementID) as HtmlGenericControl;
     div.Attributes.Add(key, value);
 }
开发者ID:xiaoxiaocoder,项目名称:AspxCommerce2.7,代码行数:16,代码来源:ApplicationController.cs

示例4: FindPagesControlByID

 public static Control FindPagesControlByID(string cid,Page page)
 {
     if (page.Master == null)
         return page.FindControl(cid);
     else
         return page.Master.FindControl(cid);
 }
开发者ID:Ravivishnubhotla,项目名称:basewebframework,代码行数:7,代码来源:UIHelper.cs

示例5: RenderCSSPath

        /// <summary>
        /// Render CSS path.
        /// </summary>
        /// <param name="page">Page instance</param>
        /// <param name="name">name</param>
        /// <param name="cssFilePath">FilePath</param>
        /// <param name="OverwriteExisting">Overwrite existing path if exists.</param>
        public static void RenderCSSPath(Page page, string name, string cssFilePath, bool OverwriteExisting)
        {
            if (page == null || page.Header == null)
                return;

            if (cssFilePath == null)
                cssFilePath = string.Empty;
            HtmlLink link = (HtmlLink)page.FindControl(name);
            //foreach (Control control in page.Header.Controls)
            //    if (control is HtmlLink)
            //    {
            //        HtmlLink link = (HtmlLink)control; 
            if (link != null)
            {
                if (link.ID.ToLower().Equals(name.ToLower()) && !string.IsNullOrEmpty(cssFilePath))
                {
                    if (OverwriteExisting)
                        link.Href = cssFilePath;
                    else
                    {
                        if (String.IsNullOrEmpty(link.Href))
                            link.Href = cssFilePath;
                    }
                    //    }
                }
            }
        }
开发者ID:xiaoxiaocoder,项目名称:AspxCommerce2.7,代码行数:34,代码来源:SEOHelper.cs

示例6: RegisterAjaxAntiForgery

 public void RegisterAjaxAntiForgery(Page page)
 {
     var ctl = page.FindControl("ClientResourcesFormBottom");
     if(ctl != null)
     {
         ctl.Controls.Add(new LiteralControl(AntiForgery.GetHtml().ToHtmlString()));
     }
 }
开发者ID:hungnt-me,项目名称:Dnn.Platform,代码行数:8,代码来源:ServicesFrameworkImpl.cs

示例7: RegisterAjaxAntiForgery

 public void RegisterAjaxAntiForgery(Page page)
 {
     var helper = CreateHtmlHelper();
     var field = helper.AntiForgeryToken();
     var ctl = page.FindControl("ClientResourcesFormBottom");
     if(ctl != null)
     {
         ctl.Controls.Add(new LiteralControl(field.ToHtmlString()));
     }
 }
开发者ID:biganth,项目名称:Curt,代码行数:10,代码来源:ServicesFrameworkImpl.cs

示例8: GetPostBackControl

 public static Control GetPostBackControl(Page page)
 {
     string evTarget = page.Request.Params["__EVENTTARGET"];
     if (!string.IsNullOrEmpty(evTarget))
     {
         return page.FindControl(evTarget);
     }
     else
     {
         foreach (string nCtrl in page.Request.Form)
         {
             Control ctrl = page.FindControl(nCtrl);
             if (ctrl is Button)
             {
                 return ctrl;
             }
         }
         return null;
     }
 }
开发者ID:AlekseyVS,项目名称:TechInStore,代码行数:20,代码来源:Admin.aspx.cs

示例9: GetControlThatCausedPostBack

        public static Control GetControlThatCausedPostBack(Page page)
        {
            //initialize a control and set it to null
            Control ctrl = null;

            //get the event target name and find the control
            string ctrlName = page.Request.Params.Get("__EVENTTARGET");
            if (!String.IsNullOrEmpty(ctrlName))
                ctrl = page.FindControl(ctrlName);

            //return the control to the calling method
            return ctrl;
        }
开发者ID:joshuatan,项目名称:CloudDocPicker,代码行数:13,代码来源:UiHelper.cs

示例10: SetPageTitle

		public static void SetPageTitle(Page page, string sTitle)
		{
			try
			{
				Literal litPageTitle = page.FindControl("litPageTitle") as Literal;
				if ( litPageTitle != null )
					litPageTitle.Text = sTitle;
			}
			catch(Exception ex)
			{
				SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
			}
		}
开发者ID:huamouse,项目名称:Taoqi,代码行数:13,代码来源:Utils.cs

示例11: GetPostBackControl

        public static Control GetPostBackControl(Page page)
        {
            Control control = null;

            string ctrlname = page.Request.Params.Get("__EVENTTARGET");
            if (ctrlname != null && ctrlname != string.Empty)
            {
                control = page.FindControl(ctrlname);
            }
            else
            {
                foreach (string ctl in page.Request.Form)
                {
                    Control c = page.FindControl(ctl);
                    if (c is System.Web.UI.WebControls.Button)
                    {
                        control = c;
                        break;
                    }
                }
            }
            return control;
        }
开发者ID:SoftArtisans,项目名称:OfficeWriter-SharePoint-Solutions-Gallery,代码行数:23,代码来源:Item2Word.aspx.cs

示例12: BindControl

 public void BindControl(object t, Page page)
 {
     foreach (PropertyInfo pi in t.GetType().GetProperties())
     {
         if (pi.CanRead)
         {
             Control ctrl = page.FindControl(pi.Name);
             if (ctrl != null)
             {
                 object value = core.GetPropertyValue(t, pi);
                 SetControl(ctrl, value);
             }
         }
     }
 }
开发者ID:nkaluva,项目名称:helper,代码行数:15,代码来源:WebFormBinder.cs

示例13: Prepare

 /// <summary>
 /// 准备控件。Ajax。
 /// </summary>
 /// <param name="page">WEB窗体引用。</param>
 /// <param name="showLink">是否显示链接。null表示使用默认值。</param>
 public static void Prepare(Page page, bool? showLink)
 {
     object ctl = null;
     if (page.Master != null)
         ctl = page.Master.FindControl("PWMessage");
     if (ctl == null)
         ctl = page.FindControl("PWMessage");
     if (ctl != null)
     {
         ((PopupWin)ctl).Visible = true;
         if (showLink.HasValue)
         {
             ((PopupWin)ctl).ShowLink = showLink.Value;
         }
     }
 }
开发者ID:niceplayer454,项目名称:cfi,代码行数:21,代码来源:MessageHelper.cs

示例14: BindModel

        public void BindModel(object t, Page page)
        {
            foreach (PropertyInfo pi in t.GetType().GetProperties())
            {
                if (pi.CanWrite)
                {
                    Control ctrl = page.FindControl(pi.Name);
                    if (ctrl != null)
                    {
                        object ctrlVal = GetControl(ctrl);
                        try
                        {
                            core.SetPropertyValue(t, pi, ctrlVal);
                        }
                        catch (Exception)
                        {

                        }
                    }
                }
            }
        }
开发者ID:nkaluva,项目名称:helper,代码行数:22,代码来源:WebFormBinder.cs

示例15: EditPostbackFireEvent_Init

		public static void EditPostbackFireEvent_Init (Page p)
		{
			
			FormView d = p.FindControl ("FormView1") as FormView;
			if (d != null) {
				d.ModeChanged +=new EventHandler(d_ModeChanged);
				d.ModeChanging+=new FormViewModeEventHandler(d_ModeChanging);
				d.ItemCommand += new FormViewCommandEventHandler (d_ItemCommand);
				d.ItemUpdating += new FormViewUpdateEventHandler (d_ItemUpdating);
				d.ItemUpdated += new FormViewUpdatedEventHandler (d_ItemUpdated);
			}
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:12,代码来源:FormViewTest.cs


注:本文中的System.Web.UI.Page.FindControl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。