.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

Issue with dynamic usercontrol loading when using ParseControl() method in VS2008

Posted By:      Posted Date: October 12, 2010    Points: 0   Category :ASP.Net

In the process of migrating an old VS2003 web app to VS2008, I'm running into this issue and haven't been able to find a resolution. 

Sample code:

"Default.aspx" has a PlaceHolder(ToolHeader).  In the Page_Load(), we dynamically load a user control passing in the virtual path to a helper method [public Control ParseUserControl(string virtualPath)].  This reads the content from the physical path, returns a Control from ParseControl() method. 

 I immediately get the following error when I open the default.aspx page in browser.

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'DynamicUC.UcControl'.

Source Error:

 Line 1:  <%@ Control AutoEventWireup="true" CodeBehind="UcControl.ascx.cs" Inherits="DynamicUC.UcControl"  %>

Can't figure out why it can't load the type.  Namespaces are looking right.   I try removing the Inherits="DynamicUC.UcControl" attribut

View Complete Post

More Related Resource Links

Usercontrol, in master page, calling a method on the main page?

I have user control called 'Header.asxc' that is registered in my master page. That user control has an image link. The clicking of this link needs to cause a dropdown on the main page to repopulate. I am comforable with delegatges, with populating the dropdown etc... My problem is I cant find the usercontrol from the page, in order to set the function event. I got this work previously when the user control was registered on the page in question but this case with the master page  has me confused. Here is a summary of the set up. 1. I put this in the Header.ascx usercontrol that is registered by the Master page. public Delegate locReloadCompanyDropdown;2. Further down in that page in the relevent _Click event, I put this. locReloadCompanyDropdown.DynamicInvoke();3. Back in the main page I declared these.. public delegate void reloadCompanies(); private event reloadCompanies doReloadCompanies;4. Finally I try to set the delegate doReloadCompanies += new reloadCompanies(PopulateCompanyDropdown); //Page.Header.locReloadCompanyDropdown = doReloadCompanies; //Header.locReloadCompanyDropdown = doReloadCompanies;You can see a couple of attempts I have made remarked out in the code above. Neither work. What am I missing here? Thanks all.  

Memory Management issue while calling COM method from .Net component

Hi all,  The Com Component Method say(GetChildresponse) requires Byte pointer as input. From .Net Component, while calling GetChildResponse  I am creating IntPtr and passing it to Component.  I am only creating the pointer in my .Net Component but allocation of bytes(CoTaskMemAlloc) happens at COM Method. After populating the pointer buffer, I am transferring to memory buffer in .Net method and Free the memorry of the pointer using "Marshal.FreeCoTaskMem" method.  Still I am not sure, whether it is deallocating the memory since the Garbarge collector wont happen immediately.  We are hitting on performance issue while doing load testing and we suspect this might be due to memory allocation that is not getting deallocated properly. Any pointers would be helpful. Thanks, Nithya Sample Code: unsafe {   // Get the physical memory address ocpHeaderBufferPointer = new IntPtr((void*)&ocpHeaderBufferPointer); temporaryResponseBufferPointer = new IntPtr((void*)&temporaryResponseBufferPointer); }   try {   try {   // Call the GetResponse of the pass through ocpChannel   new OCPChannelDSClass().GetResponse((uint)transactionId, ocpHeaderBufferPointer, out ocpHeaderBufferSize, temporaryResponseBufferPointer, out temporaryResponseBufferSize, (uint)timeout); }   catch (Exception ex) { &nbs

Dynamic method creation using code snippet

Hello, I am looking to map a method from php to .NET. There are various methods I am targeting, and most don't satisfy a one method-to-one method conversion; alot of the mapping really requires a few lines of logic thrown in, and not just "this .NET function call for this php function call." Anyway, I've defined the mappings as strings, and all I need to do is plug them into a dynamic method that will create, run the code, and return the appropriate value. I do not want to create an assembly in the process, which I think leaves CodeDomProvider out of it. And I don't want to generate my code in IL, which I think leaves MethodBuilder and DynamicMethod out of the running. Can anyone lead me in the right direction here? Is there a way to do what I am asking?   Thanks!

Calling a public method on aspx page from a usercontrol

Hello, I have a problem with calling a method on a aspx page from a usercontrol. The case is:I have 1 main page with 5 usercontrols, when something goes wrong in the code I want to display the error message in a Modalpopup Extender.I can create for each usercontrol a different modalpopup extender but isn't much easier when I make 1 popup in the aspx page.But the problem is: How should I call a method in the aspx page that open the popup? I have search several hours on the internet but can't find anything useful. Thanks,  

Issue with new controller method added

I have created an ASP.NET MVC 2 web application that runs beautifull, not a massively complex application, only 2 controllers (Home and Treatment). I have an XML data store that holds page data to be displayed for each of a set of treatments.All pages display exactly as I want them to.I have now added a new controller method for the Treatment controller with the associated XML data and it displays fine in my development environment (displays exactly as I would expect).When I deploy the new XML data and the new TreatmentController.cs file to the new site the link becomes available, but when navigated to I get a 404 page not found exception. All existing links work absolutely fine as they should.The code below shows a working controller method and the controller method that gives the 404 exception, which is pretty much identical, apart from the method and parameter names.public ActionResult Gift_Vouchers(){    GetMasterData(ViewData);    GetTreatmentData("Gift_Vouchers");    return View("Treatment");}//The above method workspublic ActionResult First_Aid_Training(){    GetMasterData(ViewData);     GetTreatmentData("First_Aid_Training");     return View("Treatment");}//The above works in dev environment, fails in liveI would assume that this is something

VS2008 Debugger Loading ScriptResources Disables Step Menu

This is a Web Forms Website Project using several Ajax controls I set some break points, then F5, IE loads the .aspx page of the C# source I am trying to debug but then the Solution Explorer opens and adds an item and tree of items labeled Script Documents > Windows Internet Explorer > MyPage.aspx and about a dozen ScriptResource.axd files (including jquery files from a library loaded using absolute referencing which I have commented out in code to determine if jQuery library was causing this wierd behavior). The Debug > Step menu selections are all greyed out and pressing any Function keys does nothing. I also recall script files loaded into IE which "looked" like I was stepping into and over or whatever but that has not been intentionally repeatable. I am very puzzled and need some help understanding how and why this is occurring and what to do about it.

Loading UserControl doesnot render panel properly with rounded corners

Hello folks,I am doing the following steps of code to load a childusercontrol into a parent and load it as a popup.Please help me correct my code below as I am not able to get the rounded corners.Below is my aspx page:<%@ Register Src="~/MessageUC.ascx" TagName="MessageUC" TagPrefix="Ctrl" %> <head runat="server"> <title></title> <link href="Styles/PopUp.css" rel="stylesheet" type="text/css" /> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <Ctrl:MessageUC ID="MsgModal" runat="server" /> <asp:Button ID="btnFireOkMessage" runat="server" Text="Show" Height="44px" Width="225px" /> </form> </body> And here is aspx.vbProtected Sub btnFireOkMessage_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnFireOkMessage.Click Dim str As String = "Header" Dim strBody As String = "Body" MsgModal.Show(TestModalPopup.MessageUC.MessageType.Success, str, strBody, 200, 500) End Sub MessageUC.ascx<asp:LinkButton ID="LinkButtonTargetCon

Namespace resolution issue when loading activities designed in VS2010 in rehosted WorkflowDesigner

Hi. I have activities that is made in VS2010, that are to be used in a rehosted WorkflowDesigner app. In the rehosted app I have a WorkflowDesigner, a toolbox with all the standard and my custom activities, and a property window. The problem occures when I load a composite activity that has reference to other custom activities (and that is drawn in the designer in VS2010). In the rehosted app the composite activity is shown almost as expected, except that all the referenced activities are shown in the designer as a red error message: "Activity could not be loaded because of errors in the XAML."  If I load the same activity in VS2010 it works.  If I remove the referenced activity in the rehosted app and adds it from the toolbox there, it works. If I draw the composite activity in the rehosted app from "the ground up", it works. If I compare the activity XAML that is saved in VS2010, and the activity XAML when opened, modified and saved in the rehosted app, I find differences in how namespaces are expressed: The Activity-XAML from VS2010 has namespace resolution at the top: xmlns:local="clr-namespace:WCFWorkflowPOC" The Activity-XAML from the rehosted app does not save namespace resolution at the top. If I add the activity in the rehosted app insted of in VS2010, it places namespace resolution

SSIS issue with dynamic excel sheet name

Hi Team, I am creating a Excel file dynamically using a script, excute sql and then the dataflow. I am not able to cretae a excel sheet name without an underscore exisitng file: "team data" even though am giving the table name in excute sql task(which is excel sheet name) as "team data" it is creating the name as "team_data" because of which the package is failing? I am able to achieve this with an underscore, as it is a client requirement to generate wihtout an underscore am posting this question. Is this an issue with Sql server 2005? Thanks, Eshwar  

Cascading Dropdown Web Method Issue



I am having an intersting issue to which I have found no solution, obviously. I am using a web service to populate a couple cascading drop downs. Evereything looks correct to me but I am getting a [Method Error 500] when I run it all. I have the <System.Web.Script.Services.ScriptService()> added to the web service so that's not the problem. What I have found while playing with it is that if I remove the arguments from the web method (ByVal knownCategoryValues As String, ByVal category As String) then it works. This of course is not helpful as I am trying to populate multiple drop downs. I can find nothing on anyone else having this issue.

I am using .NET 3.5 and Ajax DLL version 3.02... 

Also of note is that I have another website, using the same .NET and Ajax versions and this code is working fine.

I have tried everything I can think of, including my last resort tactic of smashing my face on my keyboard, and nothing is working. I am at a loss. Any help would be appriciated. Thanks.

Drop Downs:

<asp:DropDownList runat="server" ID="ddlPlateType" Width="250px" />

<ajax:CascadingDropDown runat="server" ID="cddPlateType" TargetControlID="ddlPlateType"

Opening vs2008 solution file in vs2010 - Framework targeting issue


Hey guys,

I am opening a vs2008 .sln file inside vs2010 - the conversion wizard shows up, and it goes through with no errors other than a pop up warning me that this solution needs .Net Framework 3.5 and that it is "not installed on this machine" - I chose to target it to .Net Framework 4.0 and to try to switch it later as an option.

I then bring up Properties - >Application -> Target Framework and in the dropdown, .Net Framework 3.5 is not listed - which is strange since in "Add or Remove Programs" I can see .Net Framework 3.5 is installed on my machine.

How can I get Framework 3.5 to show up in the dropdown so I can target this project to that framework?

Can't say I've ever done this, so I'm pretty sure I'm doing something wrong.


Update: I tried Method #1 here (http://blogs.msdn.com/b/robvi/archive/2004/02/17/75272.aspx) and I cannot see v3.5 - so where did it go? I'm confused why it is not in my registry but shows up in "Add or Remove Programs" list...


pass a dynamic parameter in a WCF method on HTTP GET


i have a WCF method with 2 known parameters and another one thats supposed to include a Key:Value pairs (dynamic parameter that will include an unknown number of key:value pairs).

the first question is :

i don't want to use XML as the dynamic parameter. what is the common way to pass the dynamic parameter in a WCF method? Dictionary<string,String>? json string? array of complex types? or other? ( my client - the one that uses my service, doesn't have Framework 3.5, so i suggested a framework 2.0 ways to send the parameter)

the second question :

the method  supports HTTP GET , should a dynamic parameter be passed in the URL itself or in the Header? i prefer the URL itself....


thank guys, please help ....

Creating dynamic web controls outside Init method



I am creating a dynamic <asp:Table> based on a user's selection from a DropDownList. The number of columns and rows in the table depends on the user's choice from the DropDown.

The final two columns in each row needs to contain an Edit and Delete button. I am able to create these buttons programmatically. However, I am unable to get the click event to fire.

After researching this, it appears to be the case that my dynamic Web controls need to be created in the page Init method.

However, I am unable to do this as I do not know how many table rows, columns and buttons to create, until after the user has made a selection from a DropdownList.

I would be be very grateful for some tips on the correct way to create and enable the events for my dynamic buttons, in this scenario.

Here is a brief outline of how the program currently works (this is just a brief outline I quickly sketched, small details may be wrong!):


<asp:DropDownList ID="ddlMyDropDown" runat="server" 
                onselectedindexchanged="ddlMyDropDown_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>

<asp:Table ID="tblMyTable" runat="server" /> 

Very slow repainting when moving or resizing an usercontrol in VS2008


After migrating a WinForm application with usercontrols that loads dynamically from VS2003 to VS2008 the usercontrols became extremly slowly when moving or resizing.

Gratefull for help and tips

Issue with People Search Box - Search Options Toggle teaser not loading correctly



I am experiencing an issue with the People Search Box Web Part.

When I click search options on the "People Search" web part that I have added to my Staff Portal front page it doesn't seem to render correctly. The toggle teaser tries to expand out the options but I can see the content that exists below it.

After this clicking on one of the list web parts I have and selecting the next page pf the list causes the page to fully re-render and I can see the "Search option" toggle teaser properly.

I'm wondering if this is behaviour that anyone else has seen when configuring their People Search?

I know I can turn the Search options off but this seems like a bit of a cheat and I'd rather have the functionality working properly - especially if this is a symptom of something more radically incorrect with how I have configured my front page.

Thanks in Advance


Exception loading page with Ajax enabled WebPart/UserControl ?



The AjaxControl Toolkit has been configured onto our SharePoint 2007 Server, however when we bring up a page with a WebPart+UserControl, we get the following exception:


[4300] Exception Loading CPI RPI WebPart: System.Web.HttpCompileException: c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\a112516a\152cc84\App_Web_cpirpicalc.ascx.57bd6353.duu1hbuu.0.cs(138): error CS0433: The type 'AjaxControlToolkit.ToolkitScriptManager' exists in both 'c:\Windows\assembly\GAC_MSIL\AjaxControlToolkit\3.5.40412.0__28f01b0e84b6d53e\AjaxControlToolkit.dll' and 'c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\a112516a\152cc84\assembly\dl3\4bec602a\25bcac65_13efca01\AjaxControlToolkit.DLL' 


The userControl+Ajax Portion of the WebPart works correctly when brought up under ASP.NET but not SharePoint.  

Is there anyway to force this to go to the correct version?




Dynamic Call UserControl



I need to add a WPF User control to the tab content programmatically.

can you give example ?



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