.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

UserControl not refreshing in ElementHost control

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :JQuery


I have a WinForms test app that I am using to work out the kinks of the WPF RibbonMenu Control....

I have a Winform form that I have placed an ElementHost on... I created a new WPF UserControl that I have  placed a RibbonMenu control on...

1st uc (MyMenu) design - I added a single Tab, a button and an image... this worked fine.

2nd uc (update to MyMenu) - I took the original User Control and added more Tabs, Groups and buttons etc... all is correct in the designer...

ISSUE when I go back to Form1 I see the ElementHost still but it shows the first version of the RibbonMenu and WILL NOT refresh.  I have deleted the ElementHost control saved and placed a new one of the form added the user control but it still shows the original not the new version of the menu.

The Tabs on the RibbonMenu control are there in code, and in the design interface for the WPF User Control... BUT when I run the app NO TABS????

Anyone got any suggestions?


View Complete Post

More Related Resource Links

UserControl with a control property?

Hi... I have defined a UserControl wich needs to reference another control like this: <ctrl:Cook TheList="listView1" DefaultFileName="MyRecipe"></ctrl:Cook> The code behind of the control has the property defined:         public ListView TheList { get; set; } But I have a runtime error saying: 'ListView' type does not have a public TypeConverter class. And in design time I get: Property TheList of type ListView cannot be specified as string.   I know WPF is trying to read a string instead of a ListView, but dont know the magic solution. Maybe a converter? Please suggest the simpler solution you can, because this is not a vital requirement on the app. Thanks in advance for any help  

Ajax control with usercontrol

Hi all, Can I point some properties (like targetcontrolid and CancelControlID) from ajax controls to a panel that is in a usercontrol file ? For example: aspx file<asp:modalpopupextender id="mpeRegistroAlterado" runat="server" TargetControlID="cmdInvisible" CancelControlID="cmdClose" popupcontrolid="Panel_Msgbox_Timestamp" popupdraghandlecontrolid="PopupHeader2" backgroundcssclass="Fundo_Ao_Exibir_Painel" > </asp:modalpopupextender> ascx file<asp:Button ID="cmdInvisible" runat="server" Text="Button" CssClass="Esconde" /> <asp:panel id="Panel_Msgbox_Timestamp" style="display: none" runat="server"> <div class="Div_Painel_MSGBOX"> <div id="PopupHeader2" class="Div_Painel_MSGBOX_Cabecalho">System</div> <div class="Div_Panel_MSGBOX_Body"> <br /> <br /> Message.<br /> <br /> <br />   </div> <div class="Div_Painel_MSGBOX_Buttons"> <input id="cmdclose" type="button" value="Close&q

Access UserControl Control from a JavaScript Function

I have a requirement to launch a Modal Javascript dialog box from within my usercontrol,I have done this by <code> function browseControlAction(ProjID,ControlID) { strPrompt = 'Select a Previous control action..'; strOptions = 'dialogWidth:25;dialogHeight:30;status:no;resizable:yes'; selectedAction = window.showModalDialog('browseControlActions.aspx?ProjID=' + ProjID + '&Control=' + ControlID, strPrompt, strOptions); var sControl = ' + ControlID + '; if (selectedAction != null) { alert(ControlID.toString()); alert(selectedAction); var sTest = ControlID + '_txtControlAction'; alert(sTest); var sTest2 = 'txtSummary'; alert(sTest2); document.getElementById('txtCurrentControls').innerText=selectedAction;   //this works as this a control on the page itself document.getElementById(sTest2).innerText=selectedAction;      //Ditto document.getElementById(sTest).innerText=selectedAction;    //This Fails as this is the control in the USercontrol I am trying to Access //__doPostBack('',''); }</code>can anybody tell me why I can't access the Textbox control on the USercontrol?

refreshing repeater control in asp.net

Hello all,i have been struggling a lot with repeater control refresh !! i displayed data using sql database and added 2 buttons "DEL" "ADD"these two functions are working effecinetly but my plm is am unable to rfresh the page as soon as i click the buttons am manually refreshing the data to exhibit the results please help me!!thankssujji

Dynamic Textbox List Control - problems refreshing


Ive been stuck on this one for a month:

So I have a custom control that has a list of textboxes, and a button that will dynamically add a new textbox to the list.

 So I have an addTextbox() function, that will do something like

TextbBox t = new TextBox()

 then I add it to the page.  So adding a new textbox works fine, but I have values that I want to put into each textbox and upon each page load, the values get replaced.  What I need to do is get the textboxes from the viewstate so I can use their values for other textboxes, but since they are created anonymously, im not sure how I can do that.  I tried to get the unique name and put all of them into an arraylist, then upon the next page load, load the names from the list, but the unique name isnt unique.  Thanks

Nested control's events not firing in UserControl


Hello I have a weird issue. I have a user control which I load dynamically using LoadControl. In this UserControl I have a button with assigned OnClick event, but when I click that button, the event is not fired. I'm populating the user control in UpdatePanel's Load event (I invoke __dopostback from JS).

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ServiceInput.ascx.cs"
Inherits="uPay.UserControls.ServiceInputs.ServiceInput" ViewStateMode="Disabled" %>
    <div class="PopupFoot">
        <asp:Button ID="btnAdd" CssClass="PopupADD" runat="server" OnClick="btnAdd_Click" />

    protected void btnAdd_Click(object sender, EventArgs e)
        //Method never gets called :/

 Here I load user control in the page

protected void ServicesUpdatePanel_Load(object sender, EventArgs e)
        string arg = Request.Params.Get("__EVENTARGUMENT");
        if (arg == "ServiceInput")
            int serviceId;
            if (Int32.TryParse(hdnSelectedService.Value, out serviceId))
                using (Entities db = new Entities())

In UserControl, FooCmdCanExecute (context menu) not called until after a control button is clicked.


I'm seeing an odd behavior I can't explain.  I am using a 3rd party control, and while it's possible it's an issue with that control, I wanted to inquire here to see if anyone has experienced similar behavior in other instances (unrelated to my particular 3rd party control).

I created a UserControl, comprising a ComponentONE chart and several buttons.  When the UserControl is given a data source (for the chart), it programmatically creates a ContextMenu that allows the user to configure the Y view extent for each of the data series provided in the data source.  After it's created, it's set as the ContextMenu for the chart.  The UserControl is used inside a tab on the app's main window, and is also plunked directly inside another window that can be brought up.

The UserControl defines a RoutedCommand - let's say FooCmd.  When the MenuItems for the context menu are created, their Command properties are set to FooCmd.  Also, a CommandBinding in the UserControl associates FooCmdCanExecute() and FooCmdExecuted() in the control class with the command.

The buttons in the UserControl are for data navigation - e.g. , there's one that moves the chart's "viewport" to the beginning of the data, and one for the "end".  The click handlers are not complex - essentially, they just set

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

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);

Problem merging toolstrip control placed in UserControl with MDI Form menu


I currently have an MDI application with a MenuStrip as Main Menu. The application has a child form where an instance of one UserControl with a MenuStrip is dynamically created when the form is loaded. The MenuStrip contained on this UserControl is correctly merged with the Menu of the MDI container. In response to a button click on the child form, an instance of another UserControl is created, containing a different Menu and the previously UserControl instance is discarded. The expected action is that the menu of the second UserControl will replace the menu of the first UserControl on the MDI container menu, but this is not happening and the main menu keeps the menu items of the first UserControl.

How can I force the merging of the menu contained on the second user control with the Main Menu.

Thanks in advance.

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

Unable to find Control ID of Dropdownlist Control of a UserControl from a ContentPage


I am implementing Master Pages in my existing project.

I am getting following Error:

" Unable to find control id '_ctl0:ContentPlaceH?older1:drop1:drop1' referenced by the 'ControlToValidate' property of 'valCust1'. "

I have a ContentPage which is refering to a UserContol. This UserControl has a DropDownList Control which i need to validate.

I am using a CustomValidator to validate the Dropdownlist and this CustomValidator is placed in the ContentPage.

The ControlToValidate Property of the CustomControl is assigned programatically as
(in ASPX.cs)

Control CTRL1;

ContentPlaceHolder cntplcHolder = (ContentPlaceHolder)?this.Master.FindCont?rol("ContentPlaceHol?der1");

 CTRL1 = cntplcHolder.FindCon?trol("drop1").FindCo?ntrol("drop1");

 valCust1.ControlToValidate = CTRL1.UniqueID;

My .ASPX page contains

<%@ Register TagPrefix="it" TagName="PickCntl1" Src="~/UserControls/?PickCntl1.ascx" %>

<it:PickCntl1 id="drop1" Runat="Server" Required="true" DisplayDefault="true?"></it:PickCnt?l1>


Access control within a usercontrol from Javascript


I have a javascript embedded in my extended gridview control that reference the grid control. Example:

var DataGridObj = document.getElementById(GridView1);


where GridView1 is a variable and my calling program passes the grid name. This is ok if I place my extended gridview on aspx page and run. But, how if, I have gridview in a user control and that user control is being used in aspx?

My ASPX -> My User Control -> Extended GridView.

When I check the html code, my gridview has an ID of "UserControlID_ExtendedGridViewID". Example:

In Default.aspx

<uc1:MyGrid ID="MyGrid1" runat="server" />

In UserControl (MyGrid.ascx)

<cc1:ExtendedGridView ID="GridView1" runat="server" DataSourceID="XmlDataSource1" </cc1:GridView>

and, finally in ExtendedGridView.cs

function CreateGridHeader(DataDiv, GridView1, HeaderDiv) 
    var DataGridObj = document.getElementById(GridView1);
//other part of code

HTML code:

<table cellspacing="0" rules="all" border="0" id="MyGrid1_GridView1&q

UserControl.RenderControl(writer) how to populate user control first


So I have a user control that I am using to be a "template of products" throughout the site. 

Throughout the application, I just pass the usercontrol a generic list of products and it populates a repeater.

However, I'm trying to use the .RenderControl(writer) to get the HTML from the control and it does not populate the control.
 - I've put a breakpoint on the Load event and it's not hitting it.

The only HTML it is returning is the "static" html I have on the page, nothing from the repeater.

How can I populate the control then grab the HTML?

Dim wr As New IO.

Accessing control in one usercontrol from another usercontrol



Using Sharepoint 2007, I have a Webpart with two usercontrols, UC1 and UC2. I would like to access a hidden input-field on UC1 from UC2 using javascript. Can it be done? I cannot do this:


var myInputField = $get("<%= IdOfInputfieldOnUC1.ClientID %>");


because I cannot access the input field directly in UC2. I have tried:

var myInputField = $get('<%= FindControl("IdOfInputfieldOnUC1")%>');

but no luck. I have also tried to call the FindControl function from this.Page, but still no luck. I have no problem using FindControl to access a input field created in UC2 from within UC2. By the way, the input field is declared as follows on UC1:

<input type="hidden" id="IdOfInputfieldOnUC1" runat="server"/>
Any ideas?




How can i dispose a WebBrowser Control which host on a UserControl


I found that, if I create a usercontrol that contains webbrowser, the usercontrol could not been disposed. Here is my code, could anybody help me?

public partial class Form1 : Form

    public class UserControl1 : UserControl 
      public UserControl1()
        this.Controls.Add(new WebBrowser());
        //this.Controls.Add(new TextBox());

      protected override void Dispose(bool disposing)

    public Form1()

    private void button1_Click(object sender, EventArgs e)

How to set FrameworElement Control into Grid in UserControl



How can I put controls into Grid in my UserControl in Designer when i use this control in Window?

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.
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