.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 unload UserControl's content

Posted By:      Posted Date: September 09, 2010    Points: 0   Category :WPF
Hi, I want to clear the UserControl's content from the Logical Tree UserControl control = (UserControl)RootTab.SelectedItem; RootTab.Items.Remove(RootTab.SelectedItem); AvalonWindow _avalon = new AvalonWindow(); _avalon._avalonControl.Content = control.Content;//this gives error that Specified element is already the logical child of the another element.Disconnect it first here _avaloncontrol is the usercontrol in the avalon window Thanks in advance

View Complete Post

More Related Resource Links

UserControl content generated from XML?

I am trying to generate items in wrappanel defined in XML. I am missing something here. I got to the point where I can generate content from xml but it is duplicated. With the code below, I am getting 3 stackpanels with the same content. How to pass the the other two Person nodes from XML? Thank you in advance. XML: <?xml version="1.0" encoding="utf-8"?> <persons xmlns=""> <Person> <FirstName>AAAA</FirstName> <LastName>AAAA</LastName> </Person> <Person> <FirstName>BBBB</FirstName> <LastName>BBBB</LastName> </Person> <Person> <FirstName>CCCC</FirstName> <LastName>CCCC</LastName> </Person> </persons> <p style="margin:0in 0in 10pt"> </p>  XAML: <Window.Resources> <XmlDataProvider x:Key="DashboardData" XPath="/" Source="Data/Dashboard_DataSource.xml" /> </Window.Resources> <Grid x:Name="LayoutRoot"> <UserControl> <!-- local:UserControlWP/ --> <ItemsControl x:Name="list" ItemsSource="{Binding Source={StaticResource DashboardData}, XPath=persons/Person}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <

How to avoid memory leak when removing a tabitem with usercontrol as content



I am using tabcontrol with tabitems having usercontrols as content.

When I remove a tabitem, I can see that the memory is not freed. I saw this problem has been discussed, but I have not found a complete response. I tried to do in this order, as suggested in some discussions in the forum:




.TabControlTest.Items.Remove(ti); // ti is a TabItem

ti.Content =

UserControl inside SharePoint Content Page - Unexpected Error


Hello Everyone,

 I have created a Page using Sharepoint Designer (without association it to any MasterPage. Then I registered a user control Inside this which is working perfectly fine:

<%@ Page Language="C#" %>
<%@ Register src="~/_controltemplates/mDart2.0/FetchDataFromAit.ascx" TagName="ActionItems" TagPrefix="wssuc" %>
<html dir="ltr" xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">

<head runat="server">
<META name

Resizeing children/content in a UserControl


I have a control derrived from UserControl:

public partial class DesignerComponent

SharePoint Tutorial - Content Types

SharePoint content types provide users with a way to manage and organize content in a more meaningful way. It's a reusable of settings you want to apply to a particular type of document in a library or item in a list.

Enabling Users to Maintain SharePoint Content

When SharePoint is installed as a corporate intranet, there is a considerable amount of effort involved in maintaining the content to keep the site relevant. As we discussed in the first few parts of this series, SharePoint has many built-in features to reduce the burden on the site administrator.

Some areas of the site usually contain less-dynamic information. Internal memos and corporate policies are common examples of this information. One option for this information is to post these documents in a document library. Documents in a library are often stored in a few different formats: Word, Acrobat (PDF), or HTML. Each of these formats has its drawbacks.

Application Vs. Content Pages in SharePoint

SharePoint has two types of ASPX pages. One type is the application page, also known as a _layout page. The other type of ASPX page is a content page, also known as a site page. Each of these page types is stored in a different location in SharePoint. When developers create custom ASPX pages, they must decide on the page type.

Enabling Users to Maintain SharePoint Content

When SharePoint is installed as a corporate intranet, there is a considerable amount of effort involved in maintaining the content to keep the site relevant. As we discussed in the first few parts of this series, SharePoint has many built-in features to reduce the burden on the site administrator.

Content Types in MOSS 2007

In this article I will try to describe the one of the best feature in Microsoft office Share Point 2007 called Content Types.

Content types are simply collection of contents.Each content in a Content type can have different settings.Basically it is a reusable collection of settings which you want to apply to a particular category of contents.

Content Query Web Part missing in SharePoint 2010

If you don't see content query web part listed in the web parts list, this is because you have not enabled "Search Server Web Parts" feature in site collection features. Enable this feature and content query web part will show in the list of web parts.

Unique content within master page based on conditions met


 Hi all-

I would like to present users with unique content based on certain conditions being met as they land on the home page (default.aspx).  The condition logic will be in the VB code behind Page Load event. The content will go in a content placeholder as specificed from the master page. 

However, the content change wouldn't be something small (ie making a panel or label visible or not) but rather it will be different HTML,  Divs and databound gridview content.  The HTML content will be stored in the database.

Can someone point me in the right direction for best practices on how to accomplish this?


Passing Linq Statement between master and content page


I usually work with windows forms, and am just starting to work with ASP.Net, so appologies if this is a dumb question!

I have a master page which has a search button on it. The results of this are built up using a Linq statement and if there are any results, I want to display the results in a contents page.

On the masterpage, I have the following code:

Private _res

    Public Overridable ReadOnly Property SearchRes()
            Return _res
        End Get
    End Property

 Private Sub DoSearch()
   'some code to get a linq result

    If res.Any Then
            _res = res
            Server.Transfer("SearchResults.aspx", True)
            'no results
            LabelNoRes.Visible = True
        End If
 End Sub

On the SearchResults.aspx page I have this code.

Dim m As pxSite = CType(Page.Master, MasterPage)
        If m.SearchRes IsNot Nothing Then
            Label1.Text = "Results found = " & m.SearchRes.Count
        End If

m.searchRes is always nothing. 

What am I doing wrong here?


Content page control passes as argument to javascript function


Here is the content page:


<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="JavaDynamicCopyValue.aspx.cs" Inherits="JavaDynamicCopyValue" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <script type="text/javascript" >
 function copyValue(input, output )
   ouput.value = input.value;
   return true;
 <asp:TextBox ID="txt1" runat="server" onchange="copyValue(this,document.getElementById('<%=txt2.ClientID%>'))"></asp:TextBox>
    <br />
    <br />
    <asp:TextBox ID="txt2" runat="server"></asp:TextBox>


I got a javascript run time error says output is undefined. if I view source of the page, the txt1 markup became:

<input name="ctl00$ContentPlaceHol

Composite Control which contains arbitrary content defined in .aspx of parent and thier ViewState


I want to write own control which can contain other. And I want to define content of the control in the .aspx file where the control is defined. I have written such control. But now I have issue with ViewState of inner controls of my control. The following samle illustrates the issue: I defined two asp:DropDownList ID="ddl1" and ID="ddl2" One of them is inside of my control and other is outside. When posback is occurred asp:DropDownList ID="ddl1 loses state and becomes empty. How to say ASP.net to store state of inner controls defined by this way?


<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MyControl.ascx.cs" Inherits="DynamicControls.Controls.MyControl" %>

<div class="box">
    <div class="Header-Left">
        <div class="Header-Right">
            My Control
    <div class="Content">
        <asp:PlaceHolder ID="contentPlace" runat="Server" />

Browser detection and content adaptation


hi everyone

 Here i'm creating two sites for internet version and mobile version.

 When the user enters site name, we would detect the mobile browser automatically and redirect the user to mobile version of the site .

is it possible??

if yes, please tell the way i need to develop the application for mobile web application

& in JSP?



I am typically an ASP.NET programmer, and I am familiar with ASP masterpages.

Because, I also know Java, I was handed a JSP project.

I am looking for an equivalent to <asp:Content> whereby I can wrap multiple lines of code/HTML between the open and close tag; for example like so:

<asp:Content ContentPlaceHolderID="content_id" >
<p>Hello, World</p>

However, the closest thing I found is <jsp:param name="param_title" value="param_value" />, but this is an inconvient solution because the param needs to be inclosed within double quotes, whereby multiple lines of code/HTML will need be a series of concatinated strings.

String param_value =
+ "<p>Hello, World</p>"
+ "</div>"

<jsp:param name="param_title" value="<%= param_value %>" />


Maximum memory for string ? . System.MemoryOutOfException Occurs when reading the Content of the fil



I have a C++ code which reads a file [vtk file - its similar to text file only]. and try to store it in string.

here's the code:

String^ ParallelProjectionRenderer::GetVolumeDataAsString(String^ FileName)

    vtkSmartPointer<vtkDataSetWriter> sWriter = vtkSmartPointer<vtkDataSetWriter>::New();

    String^ FileName = "D:\\Users\\...";

    char * sptName = static_cast<char *>(Marshal::StringToHGlobalAnsi(FileName).ToPointer());







    String^ result= File::ReadAllText(FileName);   [it breaks here with system.memoryoutofexception when the file size is huge]

    return result;


this code executes fine when the file size is less than 8mb.

I wanted to know whats the maximum memory allocated to the string.

As a workaround i skipped reading out in C++ code. and i tried to read the file contents in asp.net C# code and stor

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