.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

Would Control.FromHandle create a Control instance like CWnd::FromHandle in MFC would a CWnd instanc

Posted By:      Posted Date: December 04, 2010    Points: 0   Category :Windows Application
Back when I used MFC, I knew that if I needed a CWnd instance for a handle created by another program or Win32 code, CWnd::FromHandle would create a temporary instance.  Would .NET's Control.FromHandle do the same (only with a Control instance)?  Or would it limit its return values to existing instances?
Will Pittenger

View Complete Post

More Related Resource Links

Control.FromHandle returns null


I've a process: "Example.exe" (process A), which contains a main form. I launch a second instance of the process with some parameters: "Example.exe -param1 -param2" (process B). In the second instance i check for the parameters by using the args array of the Main() function and if there are any, I'd like to copy parameters from the main form of the first instance of the process to a main form of the new second instance of the process. To achieve that in the second instance I retrieve the processA.MainWindowHandle and I try to do sometihing like:

Form mainFormProcessB  = Control.FromHandle(processA.MainWindowHandle) as Form

This doesn't work because Control.FromHandle(processA.MainWindowHandle) return null.

I don't underdstand why processA.MainWindowHandle had a value equal to 509062 and when i checked for the handle value (using Spy++) I obtained the exadecimal: 7C486, which is 509062. why does Control.FromHandle(processA.MainWindowHandle) fails returning null?




Andrea Scarmagnani

how to get an array of all the asp.net textbox control inside create user wizard control?



How can I get all the textboxes inside a create user wizard control using getElementsByTagName().

Below is my JQuery code:

<script type="text/javascript">
        function addLoadEvent(func) {
            var oldonload = window.onload;
            if (typeof window.onload != 'function') {
                window.onload = func;
            } else {
                window.onload = function() {

        function prepareInputsForHints() {
            var inputs = document.getElementsByTagName("asp:TextBox");
            for (var i = 0; i < inputs.length; i++) {
                inputs[i].onfocus = function() {
                    this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
                inputs[i].onblur = function() {
                    this.parentNode.getElementsByTagName("span")[0].style.display = "none";



<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

To create a custom control and type while creating a column


HI All,

i am creating a column in the list while creating a column i will have an option for choice field on selecting choice i can see dropdown, radiobutton, Checkbox to select and  can enter list of values. and on clicking ok i will get a column with radiobutton. in newform.aspx and also in editform.aspx

so i need to create the similar functionality with my custom radio button, so on create column i need to show my custom choce on selecting this i need to show my custom radiobutton  and  can enter list of values then on selecting it then click ok to create a column, in edit form and new form i need to show a radio buttons with values.

Thanks in advance




Want to Create Table Dynamically With text Control in WinForm Csharp

Hello To All... from Many Days i m tryng to create a simple table using csharp in WinForm.Which will include textbox in each cell according the Passed No of Col & Row. but not getting the proper result. Actually i want to trace each cell data and want to save each cell data to data base : eg. in cell 11(1col & 1row) i m having Combobox which having some item list and when the user select the list item the data will save to the database. Regards, Praveen    What is the Key of Life ... Its Sharing Your Thought & Knowledge ...

Why is there no wizard control in WPF? Is there an easy way to create one, like with the TabControl

Hello, First, NO THIRD PARTY PRODUCTS!  In my search, it seems like anyone asking for a wizard control is sent to a third party to buy it.  I have no interest in buying a third party product, so if you are one of those that would suggest it, please don't, I'm simply not interested. If my understanding of page framework is correct, that is, the page is within a separate XAML file and the events are handled via its code behind, then I am not interested in such a scenario.  Nor am I interested in any fancy plumbing to make page framework work the way I want. All I want is the simple wizard control.  I'm amazed that such an important function was left out of WPF, especially since the TabControl is so close to being a Wizard Control. I'm thinking that the TabControl should be able to be made to function like a wizard, but my search finds nothing of any value.  Is the TabControl not suitable to be made to function like a wizard? Any help (other than third party products) would be greatly appreciated. Regards, Robert

Best way to create a collection of User Control objects?

Hi, I'm completely new to WPF (this week) and still grasping C# and .net as a whole. I've created a User Control which I need to add (and be able to remove) multiple instances of into a vertical list. I've so far stuck this in a Listbox although I might change this later when I'm more comfortable. So when I add the object I've created as a ListBox item it displays fine, but my issue is I need to able to delete items and add items and have those items auto update etc - so I'm guessing the WPF way to do things is to build a collection and have it bind to the list box. My question is this, what is the best type of collection to hold such objects. I've tried an Observablecollection so that I can monitor changes but when I give it a.Itemsource = Observablecollection it just presents me with a list of <Collection>. Anyone any ideas?

(trying to) Create a Listview control

Hello, I am trying to create a Winform-based Listview that uses the Client Object Model for Sharepoint 2010 to display a folder's contents similar to how a user would see it in Sharepoint. My first problem was accessing the view (which I was able with help to do), however, I found that the names of the columns in the view did not match the object property names for the objects. I am wondering if there is a "proper" way to do implement this. I am thinking I should be using a CAML query to pull back the necessary fields in the documents list, something like: My to-do list for this process is: 1: Determine the View I should be using -- is there a CAML query for that? 2: pull back the view columns w/ proper object property names -- I have the view, but the view returns improper object property names 3: Query SP (given view columns) for all docs under a certain folder something like: <RowLimit>25</RowLimit><br/> <ViewFields><br/> ... my fields from the view query ...<br/> </ViewFields><br/> <Where><br/> <Eq><br/> <FieldRef Name='FileDirRef'/><Value Type='Text'>http://myserver/documents/somefolder</Value><br/> </Eq><br/> </Where> 4: Cycle through each of the Results of step 3, transferring the info into the listview.   So, that's

How Would I Create a Trigger That Changes The Property of Another Control?

I have 4 of the same controls and to make it simple I will act like I am working with the background:  <Style x:Key="backgroundTrigger"> <Style.Triggers> <Trigger Property="GroupBox.Background" Value="Red"> <Setter Property="GroupBox.Background" Value="Blue"></Setter> </Trigger> </Style.Triggers> </Style>   In essence what I am trying to do is when the background of groupBox1 changes I want the trigger to change groupbox2's background to Red without changing GroupBox1 background. I keep running into errors because I am using the same property in the condition and in the setter and also that the the name "GroupBox2" cannot be found. Although what I am actually trying to do isn't related to the background if someone could explain how it could be it would be greatly helpful.

How can I create Dyanamic Ajax Control

Hi All,I have use all the ajax control from the http://www.asp.net/ajax website.But here I have the static control.Now in project I have to created dynamic .Please tell me the code for creating dynamic ajax control.Thank you.

Multiple instance of User Control on Page - Button Click Event

Hi, I have this Web User Control, with 3 controls:<asp:TextBox ID="txtSearch" runat="server" /> <asp:RequiredFieldValidator ID="rfvSearch" runat="server" ControlToValidate="txtSearch" Display="None" /> <asp:Button ID="btnSearch" runat="server" onclick="btnSearch_Click" /> In code behind: protected override void Render(HtmlTextWriter writer) { rfvSearch.ValidationGroup = this.ID + "_validation"; txtSearch.ValidationGroup = this.ID + "_validation"; btnSearch.ValidationGroup = this.ID + "_validation"; base.Render(writer); } protected void btnSearch_Click(object sender, EventArgs e) { Response.Redirect("ResultadoSearch.aspx?argumento=" + txtSearch.Text); } When I try to add two UserControl and I Click in btnSearch of second UserControl, txtSearch.txt returns value of first User control.How I can get the value of second txtSearch?

my custom control flow task's ui failed to create the task...

Hi.. I hope someone else has seen this. The funny thing about the error is it reports on my version 1.0 task but if you hover over the task icon in tool box it clearly indicates I have load my 1.1.1 version from the gac. Thanks=================================== Failed to create the task. (Microsoft Visual Studio) =================================== The task user interface specified by type name 'MergeBuilderTaskUI.MergeBuilderTaskUIMainWnd,Version=,Culture = Neutral,PublicKeyToken = 12345abc6789de01' could not be loaded. (Microsoft.DataTransformationServices.Design) ------------------------------For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%u00ae+Visual+Studio%u00ae+2008&ProdVer=9.0.30729.1&EvtSrc=Microsoft.DataTransformationServices.Design.SR&EvtID=CouldNotLoadTaskUIForType&LinkId=20476 ------------------------------Program Location:    at Microsoft.DataTransformationServices.Design.DtrTaskDesigner.InitializeTaskUI()   at Microsoft.DataTransformationServices.Design.DtrTaskDesigner.OnNewTaskAdded()   at Microsoft.DataTransformationServices.Design.DtsBasePackageDesigner.CreateExecutable(String moniker, IDTSSequence container, String name) =================================== The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) (mscorlib) ------------------------------Program Location:    at System.Run

How to create a new Html control which contain multiple html control ?


Hi all,

I am realizing a table with multiple rows for a Sharepoint webpart.

In this project, I would like to have a new html control which contain a LinkHtml in one column and another label in another column.

Essentially this html control would be a row used for my html table.

At the moment i am doing a row like this in the main class :

HtmlTableRow Row = new HtmlTableRow();

            //create colum 1
            HtmlTableCell _Column11 = new HtmlTableCell();
            _Column11.Style.Add(HtmlTextWriterStyle.Width, linkColumnWidth);

            // Create the input textbox
            Label _LinkButton = new Label();
            //_LinkButton.ID = claimsLinkButtonID + contentLabel;
            //_LinkButton.CommandName = IdTask;
            _LinkButton.Text = contentLink;
            //_LinkButton.Style = 

            Label _NumberOfMessagesLabel = new Label();
            _NumberOfMessagesLabel.Text = contentLabel;

            //add the textbox into column 1

            //add column 1 into row 1

            //create column 2
            HtmlTableCell _Column12 = new HtmlTableCell();
            _Column12.Style.Add(HtmlTextWriterStyle.Width, priorityColumnWidth);

            // add the label into colu

How to create custom security groups to control different custom activities?



How to create  custom security groups to control different  custom activities?

Thanks and Regards,

Swati Jain

How to create Master-Detail control in InfoPath2010?



Who can describe how to create master detail control in InfoPath2010? I couldnt find it in InfoPath2010.

Actually, I have a master table Orders and its detail OrderDetail.



How to create a server control array


Let's say I have 50 different SQL SELECT statements which each one returns one integer value...

e.g. SQL 1 = select count(row) from table where condition = 'a'

      SQL 2 = select count(row) from table where condition = 'b'

      .....  so on  .....

      SQL 50 = select count(row) from table where condition = 'zzz'


If I have 50 labels (server control) and want to put each SELECT result to corresponding labels by using a FOR LOOP.


      for (int i=0; i<49; i++)


            // connect to the database and run each SELECT statement

            // store each result to corresponding label.  (Result 1 -> Label 1, Result 2 -> Label 2, .........., Result 50 -> Label 50)



I have all 50 SQL SELECT statements to run in a loop and each one has the result that I want.

I need to display all 50 results in 50 different labels (one-to-one) and just don't know how I need to name each label, so that I can use them like a array.


In VB6 (back in th

go back to Create User Step on CreateUserWizard control



I'm using a CreateUserWizard do add users to a web app. Everything is working great, but on thing... the Complete Step :-/

I don't need that extra step, and more, i'm using this control as an option where the administrator of the application adds his trusted users to the site. So, its part of a web form that has a list of users on one side and the CreateUserWizard on the other.

What i tried to do, and was unsuccessful, was to change the ActiveStepIndex back to 0 then the user creation was completed, but this didn't work. The Complete Step still appears. Also, i added this to the continue button event and it did nothing either: CreateUserWizard1.ActiveStepIndex = 0;

Is there any way i can "hide" this step? If not, is there a way to go back to the Create User Step when i click the Continue button in the Complete Step?


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">
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