 |
|
 |
Hi, I have created some user controls. I have dynamically loaded one usercontrol say "ChildControl.ascx" in another user control say "ParentControl.ascx" using the following code:
Dim tempControl As New Control tempControl = LoadControl("~/folder/folder2/ChildControl.ascx") Dim objChild As ChildControl = TryCast(tempControl, ChildControl)
I have converted the user controls into custom controls. Then I am using all these control as you mentioned in this post. But I am getting the following error while the parent control is loading the child control dynamically:
The file '/folder/folder2/ChildControl.ascx' does not exist.
How should I solve this problem?
I also want to generate output to single assembly/dll for all the user controls, and I will use this single dll to register any usercontrol. how is it possible?
Regards,
modified on Friday, August 28, 2009 3:47 AM
|
|
|
|
 |
|
 |
problem with VS 2008 plaese help me :(
|
|
|
|
 |
|
 |
can I add the generated custom controls in the toolbox, so that I can drag them to a web page just like the standard asp.net controls ?
Thanks
|
|
|
|
 |
|
 |
Its an Excellent Article... I succeeded in doing this. Iam trying to create login Control, where in custom control i create only 2 textboxes as userid and password and on normal web application i make use of this .dll file where i use button control ...on click my textboxes text should authenticated? problem is how should i refer individual control id from custom control in my web application like "select * from tblregistration where userid ='" + textbox1.text + "' AND passwd ='" + textbox2.text + "'"; //customcontrolID.------? what plz help me tanx
|
|
|
|
 |
|
 |
A very good technique...
It solved my problem.
Thanks,
Ahmed Fahad
|
|
|
|
 |
|
 |
Dear all; can you help me? i try to do it but i failed!
when i add new web user Control the source code is
Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl"
when i try to change it to
Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl.ascx.cs" ClassName="Test.WebUserControl"
first i lost the relation with the WebUserControl.ascx.cs file and i wrote the c# code as
script runat="server"
protected void Button1_Click(object sender, EventArgs e) {
} /script
second point when i add the web deployment project and change the output assemblies to "create a separate file for each page and control" and build the project
the result Validation Complete ------ Build started: Project: createwebuser_deploy, Configuration: Debug Any CPU ------ if exist ".\TempBuildDir\" rd /s /q ".\TempBuildDir\" C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v /createwebuser -p "D:\My Documents\createwebuser" -u -f -d -fixednames .\TempBuildDir\ if exist "D:\My Documents\Visual Studio 2008\Projects\createwebuser\createwebuser_deploy\Debug\" rd /s /q "D:\My Documents\Visual Studio 2008\Projects\createwebuser\createwebuser_deploy\Debug\" if not exist "D:\My Documents\Visual Studio 2008\Projects\createwebuser\createwebuser_deploy\Debug\" md "D:\My Documents\Visual Studio 2008\Projects\createwebuser\createwebuser_deploy\Debug\" if exist ".\TempBuildDir\" rd /s /q ".\TempBuildDir\" ========== Build: 2 succeeded or up-to-date, 0 failed, 0 skipped ==========
when i open the Debug\bin folder i get only App_Web_default.aspx.cdcab7d2 file for the aspx page and i don't get the dll file for the web user control ??? can i get help ????
regards
|
|
|
|
 |
|
 |
I'm having the same problem! Does anyone know if this is possible on VS 2008?
|
|
|
|
 |
|
 |
Despite repeatedly installing the WDP in VS 2005 SP1, the option to "Add Web Deployment Project" doesnt display for a web application project. It displays only for a website project. What am I missing??
When I create my controls in a website and use the "Add Web Deployment Project" and build, I am getting issues with "Null object reference" ....
So could you tell me how to get that menu "Add Web Deployment Project" for web app project?
|
|
|
|
 |
|
 |
Why can't we just do this: Create a custom control project. Put our user control in the project as an embedded resource. Read in our embeeded resource as design time html or as create child controls...
And then bam...we have it - sure would be nice don't you think.
|
|
|
|
 |
|
|
 |
|
 |
I will try to do this - but one thing I would like to know more about and yet have found little information on The HtmlEmptyControlBuilder - do you know of this component and how to use it - there are no examples on MSDN, and there does not seem to be anything on the web...searching Google Excite etc..
|
|
|
|
 |
|
 |
Hi, I have a user control that is used in several other user controls. The control has some buttons and i want to set their properties from let's say from one of the user controls. i have this code:
protected Button btnPrevious;
and the property public bool EnabledPrevious { get { return btnPrevious.Enabled; } set { this.btnPrevious.Enabled = value; } }
from the other user control i have this code in the Page_Load method:
WebControl1 Top = new WebControl1(); Top = (WebControl)Page.LoadControl("path to the control"); Top.EnabledPrevious = false;
but the button Previous remains Enabled. Can please anyone help me?
|
|
|
|
 |
|
 |
Please help.
This technique worked for me with VS.NET 2005.
Unfortunately, this technique does not seem to work with VS.NET 2008.
The error is that at run-time, the contol is null.
Do you have any suggestions?
Please advise.
Thank you.
-- Mark
|
|
|
|
 |
|
 |
Dear Mark,
I am using this in MS VS 2008 without any troubles. Everything is the same. Please check that you use the WebDeployment project extensions from Microsoft Web Site for MS VS 2008. It is different than MS VS 2005. In my article I attach only MS VS 2005. Please give me a e-mail and I will send you this 'msi' file in case that you can not find it.
Dimitar Madjarov
|
|
|
|
 |
|
 |
You are quite right. I was wrong. My code had a namespace error. Thank you.
|
|
|
|
 |
|
 |
its working fine in Microsoft Internet Explorer.But the functionality in that ASPX page is not working in other browsers like Mozilla. I can't see some controls, which results in not meeting the requirement itself. So, I was just wondering about this issue .
what might be the problem here, can you please help me from this.
|
|
|
|
 |
|
 |
In Page_load of user control if i reference any of the controls i get the error as Object reference not set to an instance of an object. In other blogs i saw similar error when converting user controls to custom controls but never saw any solution regrading this issue. Please let me know if you have any solution for this issue
|
|
|
|
 |
|
 |
Hi. Please give me 1 hour to reach my work and I will send you an example code.
Faithfully yours, Madjarov.D.N
Dimitar Madjarov
|
|
|
|
 |
|
 |
Hi,
This is the first option:
In your control in the 'ascx' file you have to use exactly this file as 'server' side code to manage your events and pages. Like the example below:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WUCGridToGrid.ascx.cs" ClassName="TGtoG.WUCGridToGrid"%> <%@ Register Assembly="DevExpress.Web.ASPxGridView.v8.1" Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { //Put your code here................ } </script>
Faithfully yours, Madjarov.D.N
Dimitar Madjarov
|
|
|
|
 |
|
 |
Hi,
This is the second options: When you add the generate from WebDeploy project assembly in your new aspx page where you like to use the control in the C# code you may use and manage all kind of controls placed in your converted user control as the next example:
protected override void OnPreRender(EventArgs e) { if (!this.Page.IsPostBack) { //Make a reference with left grid control if (myConvertedUserControl.FindControl("grdLeftGrid") != null) { ASPxGridView gridLeft = (ASPxGridView)myConvertedUserControl.FindControl("grdLeftGrid"); gridLeft.Settings.ShowVerticalScrollBar = true; gridLeft.Settings.ShowColumnHeaders = true; } base.OnPreRender(e); } }
Here 'myConvertedUserControl' is the server control which we convert from user control. And 'grdLeftGrid' is a DevExpress grid control which I place inside my web user control. By this way you may access all controls, public propertirs and override publick events inside the user control.
Faithfully yours, Madjarov.D.N
Dimitar Madjarov
|
|
|
|
 |
|
 |
Thank you so much Madjarov.
Your first option works fine. I did not understand why the same thing does not work when Page_Load is in Code Behind file. That is a million dollar question for me now.
|
|
|
|
 |
|
 |
I have another question, is there a way to add converted custom control to toolbox. when i try to add converted control to tool box it gives the error as "There are no components in the control that can be placed on the toolbox". Your help is really appreciated
|
|
|
|
 |
|
 |
Yes, there is a way. Create an standard server control with MS VS Studio 2005/2008 wizard. And in the class which will be generate from this wizard inherited the class of your converted control. This will work.
Dimitar Madjarov
|
|
|
|
 |
|
 |
How can we create a class with server control wizard? according to my knowledge we just place the wizard control on the web page and customize the wizard steps. but how can we create a class from this wizrad?
|
|
|
|
 |
|
 |
Mr.Dimitar Madjarov,
Thanks for the article .
Really a good piece of article and helpful to people who are struggling to convert their web user controls to custom controls(dlls).
Can you help me in this issue...
I am done with your steps and I got what I need like dlls, and used in other projects, its working fine in Microsoft Internet Explorer.But the functionality in that ASPX page is not working in other browsers like Mozilla. I can't see some controls, which results in not meeting the requirement itself. So, I was just wondering about this issue .
what might be the problem here, can you please help me from this.
Manoj Sriram can u mail me at: srirammanoj@hotmail.com
|
|
|
|
 |