.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

A User Control which contains a WPF Control hosted in ElementHost can not SHIFT+TAB back (but can TA

Posted By:      Posted Date: October 02, 2010    Points: 0   Category :WPF
For some reason, user controls which are built out of WPF hosted controls, seem to be unable to SHIRT+TAB back out of the control on the form.  One can TAB forward to the next user control without issue, however, unless you wish to cycle the form, there is no way to go back.  To see this in action, create the following single user control:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
    public partial class TextForFun : UserControl
        System.Windows.Controls.TextBox wpfTextBox1 = new System.Windows.Controls.TextBox();
        MyElementHost myhost = new MyElementHost();

        public TextForFun(int point)

            myhost.Location = new Point(0, 0);
            myhost.Size = new Size(50, 50);

View Complete Post

More Related Resource Links

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?


how to expose a dependecypeoperty of a control hosted inside anther one in a user defined control




I have a user defined control.

It inherit from grid and it has many controls in it and one of it is a textblock


I what to expose the dependecyproperty of the textbox how can I do this



I mean i want to do something like



dim MyControl as mycontrol

mycontrol.fontfamily    wher the fontfamily is actually   mycontrol.innertextblock.fontfamily



Acessing controls in usercontrol in javascript function where user control hosted in webpart



1how to acess controls in usercontrol  in javascript function where user control hosted in webpart


2)How to retieve values from javscript code to server side

details as follows

StringBuilder controlString = new StringBuilder();
            controlString.Append("<p>" + CurrentPage.ToString() + "of " + TotalPages.ToString() + " </p>");
            for (int intIndex = 1; intIndex <= TotalPages; intIndex++)
                controlString.Append("<li><a hre

Choosing Between a User Control or Web Part for SharePoint

SharePoint will only display Web Parts on a page. However, there are publicly available shims that allow you to write user controls and have them be displayed as a Web Part. From SharePoint's point of view, the shim is a Web Part. From the point of view of the user control, the shim is simply a control in .NET that is including the user control

Building Re-Usable ASP.NET User Control and Page Libraries with VS 2008


I am having problems with a user control. I want my solution to have a separate project for holding my user controls.

The main project can get a reference to this user control project and can import this user control dll into my main project. 

Thanks in advance,

Dheeraj Mittal


Multiple Instances of User Control


I have a user control that I place on a page severl times.  When I make a selection on a ddl in one one control the SelectedIndexChanged event fires for all the control on the page for that ddl.  So I get duplication of an insert that I do.  Is there a way to make sure these events are isolated so this doesn't happen.


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>

Persist data in a dynamically populated ListBox in a user control


Hi All,

I am trying to persist data in a dynamically populated ListBox in a user control. Here are the details

I have a user control which contains a a listBox and button. On Page_Load of user control I am populating the ListBox control with some values. On Click of button, I am trying to fetch the values which I have selected in ListBox. Though this seems very simple and straight forward I am unable to fetch values.

My Page_Load Function

void Page_Load(object sender, EventArgs e)










My Click Function

Protected Void Button1_Click(object sender, EventArgs e)


       string strValue = listBox.SelectedValue



I have placed brake point at Page_Load and on click function, I am seeing that the moment the breakpoin

Category attribute of user control property does not work correctly in categories tab.



I have a User Control (ascx) and a property which a want to display in my categories tab in Visual Studio in the category named "Styles".

[Category("Styles"), DefaultValue(""), Description("The value for formating something.")]
public String MyFormatProperty
set { /* the code for set */; }
get { /* the code for get */; }

And here is the problem: Actually I do not need a get, because I only have to set the property (write only property). But when I omit the get, the property is displayed in the "Misc" category in the categories tab in Visual Studio. Only when I code the get as well, then the property is displayed correctly in the "Styles" category in the categories tab in Visual Studio.

Does anybody know why? How can I display the category correctly only with set?

Thanks, S.

OnItemCommand not firing in Templated User Control


I have a templated user control with single instance template attribute. It works great for everything except the following scenario:


    <asp:UpdatePanel ID="upDirectoryBrowser" runat="server">
        <asp:AsyncPostBackTrigger ControlID="fsBrowser" EventName="FolderSelected" />
        <asp:AsyncPostBackTrigger ControlID="flsBrowser" EventName="FileSelected" />
        <asp:AsyncPostBackTrigger ControlID="flsBrowser" EventName="LinkSelected" />
        <table width="100%">
                <td style="width: 230px;">                        
                    <ntc:FolderSelector ID="fsBrowser" runat="server" OnFolderSelected="fsBrowser_FolderSelected"
                    OnControlException="fsBrowser_ControlException"  /> 
                    <ntc:FileSelector ID="flsBrowser" runat="server" OnFileSelected="flsBrowser_FileSelected"
                    OnControlException="fsBrowser_ControlException" O

"Type ASP.x is not defined" error for dynamic user control when publishing updateable


I have a user control (ContainerCtrl) which programmatically instantiates another user control (SimpleCtrl) in OnLoad. It builds and runs fine, but when I publish it I get the error "error BC30002: Type 'ASP.SimpleCtrl' is not defined." (If I publish without the "updateable" option there's no error, but I need the site to be updateable.)

I assume this has to do with the particulars of how the assembly(ies) are built for the different compiler options. My question is, how can I get it to work properly for "updateable" publishing?

VS 2008 / .NET 3.5 sp1

The code follows (web.config is the default from Visual Studio).

Many thanks, Dave


<%@ Control Language="VB" ClassName="SimpleCtrl" CodeFile="SimpleCtrl.ascx.vb" Inherits="_SimpleCtrl" %>

    Simple control


Partial Class _SimpleCtrl
    Inherits UserControl

    'Nothing to see here.

End Class


<%@ Control Language="VB" CodeFile="ContainerCtrl.ascx.vb" Inherits="_ContainerCtrl"

Least Privilege: Teach Your Apps To Play Nicely With Windows Vista User Account Control


User Account Control in Windows Vista keeps the OS safe from intentional and accidental configuration changes.

Chris Corio

MSDN Magazine January 2007

GDI+: A Primer on Building a Color Picker User Control with GDI+ in Visual Basic .NET or C#


Although most developers and APIs use the RGB scheme when working with colors, it's not the only available way to represent or select colors. For instance, the standard Windows color-selection dialog box allows you to work with the HSL color scheme in an indirect way. In this article, the author describes several color selection schemes, and uses GDI+ (via the System.Drawing namespace) to create a component that makes it possible for your own applications to provide a simpler, friendlier color chooser. Along the way, you'll get tips to help you use GDI+ in your own apps.

Ken Getz

MSDN Magazine July 2003

Passing Primary Key to User Control to Display Record Detail


I'm building a user control to display detail information on a parent record. The user control will be displayed via an Ajax Modal Popup. The user control works and is displayed when expected. The problem that I'm having is that I'm not able to pass in the primary key for the parent. The control is displayed via the _ItemCommand event of a Repeater. In the markup for the user control, I explicity set the ContactId to 0 to avoid an error when the control loads (its still underdevelopment, eventually that I'll check if the value is valid).

I was assuming that I could change the property in the _ItemCommand event, but obviously its not working.

In the Page_Load event this code successfully sets the ContactId property of the control. The _ItemCommand event appears to set the value. However when I set a test label on the user control to the Me.ContactId, its showing '0' as if it was never passed in.

        UserControlContactDetail.ContactId = "1462"
        test.Text = UserControlContactDetail.ContactId

    Protected Sub RepeaterDirectory_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles RepeaterDirectory.ItemCommand

Protected Sub RepeaterDirectory_ItemCommand(By

Rendering User Control content


I have a scenario where, the content is:
 ASP.NET Controls
      User Control
 ASP.NET Controls

The entire div code is rendered and is sent at a mail using the code:

Dim sw As New StringWriter()
Dim w As New HtmlTextWriter(sw)
Dim s As String = sw.GetStringBuilder().ToString()

This works fine except that the User Control does not get rendered.

Any way out, so that the User Control content is also rendered ?

asp expression bound to user control parameter?


How can I get pass the DataKey of a GridView to a usercontol, preferably without code behind.

Why doesn't this work:

<ucOrderDetails:AJAX_OrderDetail ID="od1" runat="server" OrderNumber='<%# GridView1.SelectedValue.ToString() %>'  />

GridView1 is just a list of orders with a DataKey of OrderNumber.

od1 is not inside of a databout control, does it need to be?

Dynamically load user control without postback


Hi all,

I need urgent help. (c#coding)

In my base page, I have a dropdownlist control which loads different usercontrols on selectedindexchanged event.

While loading these usercontrols, my page postbacks all the page. I used updatepanel but again same problem.

Is there any way to load controls without postback? I Really need help as soon as possible.

Here is my code:

protected void Page_Init(object sender, EventArgs e)
        if (Session["control"] != null)
            string c = Session["control"].ToString();
            if (c == "1")
                iuc = (IlkogretimUC)LoadControl("~/Controls/Ilkogretim.ascx");
                dl.SelectedValue = Session["control"].ToString();
            else if (c == "2")
                luc = (LiseUC)LoadControl("~/Controls/LiseUC.ascx");
                dl.SelectedValue = Session["control"].ToString();
            else if (c == "3")
                youc = (YuksekokulUC)LoadControl("~/Controls/Yuksekokul.ascx");
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