.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to get the actual control object from FieldInfo in .NET Reflection?

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :WPF

Hello, I need to get the "control" object from fieldInfo object in C# using reflection.

        Control mainControl = Control.FromHandle(a_hWnd);            
object oMainControlObject = mainControl;

FieldInfo[] fieldInfos = oMainControlObject.GetType().GetFields(BindingFlags.Instance | BindingFlags.<

View Complete Post

More Related Resource Links

How to get the actual control object from FieldInfo in .NET Reflection?


Hello, I need to get the "control" object from fieldInfo object in C# using reflection.

        Control mainControl = Control.FromHandle(a_hWnd);            
object oMainControlObject = mainControl;

FieldInfo[] fieldInfos = oMainControlObject.GetType().GetFields(BindingFlags.Instance | BindingFlags.<

How to control the text and other properties in ResourceDictionary object that i wrote ?

I wrote some ResourceDictionary. This ResourceDictionary is actuly a button that i use - I created this button by using Rectangle and TextBlock ==> that mean that the my xaml look like the code below. The problem is that i cant change the font size and the text of the TextBlock. I can change is just from the xaml of the template. And ... How can i define some variable that will control on the rectAngle redius in runtime ? Someone can help ?? ? Thanks. ...<ResourceDictionary> <Style x:Key="MyBtn" TargetType="{x:Type Button}"> <Rectangle ... <TextBlock.... </ResourceDictionary> ...

Converting a System.Windows.Control.Image object to byte array.

Hi i need to convert a specific System.Windows.Control.Image object into an (int) array, because i'm trying to convert a silverlight application into a wpf project. private void createGi02GradBrush()<br/> {<br/> WriteableBitmap oWriteableBitmap = new WriteableBitmap(256, 256);<br/> Image oImage = new Image();<br/> oImage.Arrange(new Rect(0, 0, 256, 256));<br/> oImage.Measure(new Size(256, 256));<br/> oImage.Source = new WriteableBitmap(256, 256);<br/> Gi02GradShaderEffect oGi02GradShaderEffect = new Gi02GradShaderEffect();<br/> oGi02GradShaderEffect.pArray = oPImageBrush;<br/> oGi02GradShaderEffect.gi1GradArray = oGi1GradImageBrush;<br/> oImage.Effect = oGi02GradShaderEffect;<br/> oWriteableBitmap.Render(oImage, null);//here<br/> oWriteableBitmap.Invalidate(); <br/> this.oGi02GradImageBrush = new ImageBrush();<br/> this.oGi02GradImageBrush.ImageSource = oWriteableBitmap;<br/> } I've found some similar topics however Image object is not the same and most of its methods aren't available. Here I'm rendering a writablebitmap with a given Image object, but in wpf we need an array. oWriteableBitmap.Render(oImage, null); Any idea? Thanks. Joseph.  

Object Reference Error While Rendering Menu Control


I am having a problem with rendering a menu control inside a server control. I am getting an error in the RenderContents override method when I try to render the Menu Control. The error I am getting is an Object Reference error. The code is below...

[ToolboxData("<{0}:Login runat=server></{0}:Login>")]
    public class Login : CompositeControl
        #region Members

        Label tst;
        Menu loginMenu;
        MenuItem mainLoginItem;
        MenuItem loginItem;
        MenuItem usernameItem;
        MenuItem passwordItem;
        SubMenuStyle subMnuStyleControl;
        SubMenuStyle subMnuStyleMenu;

        bool isLoggedIn = false;


        #region Properties

        public bool IsLoggedIn
            get { return isLoggedIn; }

            set { isLoggedIn = value; }


        #region Overridden Events

        protected override void RenderContents(HtmlTextWriter writer)



        protected override void OnInit(EventArgs e)

            #region Add CSS references
            string cssUrl = Page.ClientScript.GetWebResourceUrl(this.Ge

Object reference not set to an instance of an object in Nested Repeater Control of CheckBox List con

 if ((item.ItemType == ListItemType.Item) || (item.ItemType == ListItemType.AlternatingItem))
                Repeater rptsub = (Repeater)item.FindControl("rptsub");
                CheckBoxList Chksub = (CheckBoxList)rptsub.FindControl("Chksub");
                Label lblsubroot = (Label)rptsub.FindControl("lblsubroot");
                DataRowView row = (DataRowView)e.Item.DataItem;
                RootId = Convert.ToInt32(row["IdApplication"].ToString());
                MetadataPermissions metadataPermissions = new MetadataPermissions(); ;
                DataSet rptRootValues = new DataSet();
                rptRootValues = metadataPermissions.GetrptSubMenus(RootId);
                DataRow[] drows = rptRootValues.Tables[0].Select("IdApplicationroot = " + row["IdApplication"].ToString());
                foreach (DataRow chkpermsns in drows)
                   ListItem li = new ListItem(chkpermsns["PermissionName"].ToString());


<asp:Repeater ID="rptroot" runat="server" OnItemDataBound="rptroot_ItemDataBound">

How to access label object in a user control


I thought I did something like the following inorder to find the labels in a user object but when I revisited it, it did not work.  Any ideas???




using System.Collections.Generic;







page inside update panel doesn't refresh the session object after postback of any control



I have many controls like dropdown, radiobuttonlist, etc on my page and I put all these controls inside the update panel so that the page doesn't look to be posting back when something is selected. Now the working on the page is very smooth. But the session object isn't getting refreshed even if I postback to the server and as a result even if the users are working on the page they are being sent to the login screen after 20 mins.

Is there anyway where I could put all the controls in update panel and still refresh the session after any postback(dropdown selection)

Any help is greatly appreciated.

Thanks in advance

DataBinding not updating underlying business object when changing control property from code


I have a custom data form control that in code generates databindings between the selected custom business object (LLBL) and the various controls on the screen. Everything works in that I set the DataContext to the selected business object and the data appears in the GUI. If the user changes anything on screen, the data is getting updated into the business object.

However, now I have some custom logic that when the user presses a button I need to update some fields. Currently I'm setting this data directly into the controls, setting the new value into the property that is bound. However, the data is not getting pushed back into the business object.  I had this same issue building WinForm apps in that databinding only fired if the user was in the control and left it.

Does the same thing apply to WPF? How can I get ANY change on say a TextBox's Text property whether via user interaction or from C# code to push that value into the bound business object property?


new custom control using object model?


Is it possible to create our own ribbon ?if possible,

How To add new ribbon and under that new  custom controls to ribbon using server object model?


Change Control - Who changed this object?

We have a team of DBAs. A maintenance plan was changed last week, we can see
a new modified date, but who made the change?
In the wider question - is it possible to log which users are making changes
to objects in SQL server 2005?
Gerry Hickman
London (UK)

Nested GridView Control returns "Object variable or With block variable not set" when outer GridView


Nested GridView Control returns "Object variable or With block variable not set" when outer GridView returns rows.

The Nested GridView Control works as long as the outer GridView returns rows, the following code works:


Protected Sub GridViewReport_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridViewReport.RowCreated

          If e.Row.RowType = DataControlRowType.DataRow Then

                 Dim myStatus_ID As SqlDataSource = CType(e.Row.FindControl("sqlDeviceStatusAssign"), SqlDataSource)
                 If Not e.Row.DataItem("Status_ID") Is Nothing Then
                                  myStatus_ID.SelectParameters(0).DefaultValue = e.Row.DataItem("Status_ID")
                 End If

       End If

Bind Repeater Control with JSON object


I have dropdown in the aspx page. I am calling JQuery on dropdown chnage and JQuery is calling GenericHandler.ashx . The Handler is retuns 

Serialize JSON  string. I ned to bind  my Repeater control with this JOSN object any can have idea . could you please help fro me. here I am giving  my sample aspx page code

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>

<script type="text/javascript"  src="Shared/jquery-1.4.2.js" ></script>
<script type="text/javascript">
    var _entityId = 1;
    var _rowCount  = 5;
  var _pageIndex  = 8;

how to add treeview control to sharepoint 2010 using object model?

how to add treeview control  to sharepoint 2010 using object model?

C# following exception while reflection of dynamically created control.


ControlType = "System.Windows.Forms.WindowsFormsApplication1." + "PictureBox1"; System.Reflection.Assembly asm; asm = typeof(Form).Assembly; ControlObject = (System.Windows.Forms.Control)asm.CreateInstance(ControlType); ControlObject.Name = ControlName; The next code generated following exception for me: ControlObject.Name = ControlName;

NullReferenceException was unhandled Object reference not set to an instance of an object.

sys.extended.UI.PositioningMode.Absolute is null or not an object ,callout ajax control



I'm using  callout ajax control but i'm getting an error "sys.extended.UI.PositioningMode.Absolute"

Any ideas??

How Can I Set the ImageSource Property of an Image Control to a Image Object?

Basically, I have an image control and want it to display an Image object. Every example always uses a URI path, but I want to use an existing image.

SPGridView Control: Paging Error - "Unable to cast object of type 'System.Int64' to type 'System.



I'm creating project in VS 2010 using VisualWebPart. I'm using SPGridView for my grid in the web part. To acheive this, I've done following:

I added following xml in my ascx control

<SharePoint:SPGridView runat="server" ID="grdView" AutoGenerateColumns="false" AllowPaging="true" PageSize="2&
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend