Beispiel #1
0
 /// <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;
 }
        /// <summary>
        /// Initialize the control to page.
        /// </summary>
        private void InitControlToPage()
        {
            System.Web.UI.Control controlToPage = this.Parent.FindControl(this.ControlToPage);

            if (controlToPage != null)
            {
                switch (controlToPage.ToString())
                {
                case "System.Web.UI.WebControls.DataGrid":
                    System.Web.UI.WebControls.DataGrid dataGrid = (System.Web.UI.WebControls.DataGrid)controlToPage;

                    dataGrid.AllowPaging        = true;
                    dataGrid.AllowCustomPaging  = false;
                    dataGrid.PagerStyle.Visible = false;
                    dataGrid.PageSize           = this.PageSize;
                    dataGrid.CurrentPageIndex   = this.CurrentPage - 1;
                    dataGrid.DataBind();

                    if (this.RecordCount == 0)
                    {
                        this.RecordCount = GetRecordCount(dataGrid.DataSource);
                    }

                    break;
                }
            }
        }
Beispiel #3
0
        public static void RegisterWidgetScript(Control controlToBind, 
            string[] scriptsToLoad, 
            string[] cssToLoad, 
            string[] htmlSnippetsToLoad,
            string startUpCode)
        {
        
            var scriptLoader = new StringBuilder();

            scriptLoader.Append("ensure( { ");
            
            if (scriptsToLoad != null)
            {
                scriptLoader.Append("js: ['");
                scriptLoader.Append(string.Join("','", scriptsToLoad));
                scriptLoader.Append("'],");
            }
            if (cssToLoad != null)
            {
                scriptLoader.Append("css: ['");
                scriptLoader.Append(string.Join("','", cssToLoad));
                scriptLoader.Append("'],");
            }
            if (htmlSnippetsToLoad != null)
            {
                scriptLoader.Append("html: ['");
                scriptLoader.Append(string.Join("','", htmlSnippetsToLoad));
                scriptLoader.Append("'],");
            }

            if (scriptLoader[scriptLoader.Length - 1] == ',')
                scriptLoader.Length--;

            scriptLoader.Append("}, function() { ");
            scriptLoader.Append(string.Format("{0}", startUpCode)); 
            scriptLoader.Append(" } );");

            ScriptManager.RegisterStartupScript(controlToBind, controlToBind.GetType(), controlToBind.ToString() + DateTime.Now.Ticks.ToString(), 
                scriptLoader.ToString(), true);
        }
		object GetBoundValue (Control controlContainer)
		{
			if (DataField == ThisExpression)
				return controlContainer.ToString ();
			else {
				IDataItemContainer dic = (IDataItemContainer) controlContainer;
				if (boundProperty == null) {
					boundProperty = TypeDescriptor.GetProperties (dic.DataItem) [DataField];
					if (boundProperty == null)
						new InvalidOperationException ("Property '" + DataField + "' not found in object of type " + dic.DataItem.GetType());
				}
				return boundProperty.GetValue (dic.DataItem);
			}
		}
Beispiel #5
0
 public void Write(Control control)
 {
     if (control == null)
         return;
     if (m_Content.Length != 0)
     {
         if (m_Grid == null)
             m_Allcontent.Append(m_Content);
         else
             m_Grid.Controls.Add(new LiteralControl(m_Content.ToString()));
         m_Content = new StringBuilder();
     }
     if (m_Grid == null)
         m_Allcontent.Append(control.ToString());
     else
     {
         if (m_Grid.Controls.Contains(control))
             m_Grid.Controls.Remove(control);
         m_Grid.Controls.Add(control);
     }
 }
		protected virtual object GetValue (Control controlContainer, string fieldName, ref PropertyDescriptor cachedDescriptor)
		{
			if (DesignMode)
				return GetDesignTimeValue ();
			else {
				if (fieldName == ThisExpression)
					return controlContainer.ToString ();
				else {
					IDataItemContainer dic = (IDataItemContainer) controlContainer;
					if (cachedDescriptor != null) return cachedDescriptor.GetValue (dic.DataItem);
					PropertyDescriptor prop = GetProperty (controlContainer, fieldName);
					return prop.GetValue (dic.DataItem);
				}
			}
		}