Read controls used on page or usercontrol from another project - c#

I have 2 projects in a solution. A web project and a forms project and i want the forms project to list the webcontrols that are used inside a user control (.ascx) in the web project.
I can read the .ascx as a textfile and parse it, but i was wondering if there is a better way to do this. I can reference the web project within the forms project, but i don't know how to read/loop through the controls of a page or user control as they are protected.
Can this perhaps be done with reflection? Or is there another approach i should take?

Related

Mixing VB.net Web Forms application project with C# Web forms application project in Same solution

I am new in .NET world and very new to this kind of configuration and stuck to start the changes requested by business user.
We have VB.net web form apps which was created long time back. We were recently requested to add few more functionality and the team wants to add those new pages as C# webform. I know it is possible to have many projects in one solution. Now, I need some guidance on how to integrate those two projects.
I have added a new asp.net C# web form project under the solution where the old vb.net project exists and added aspx page in C# webform project.
Now from VB.net project I want to redirect users to this c# webform project and Viceversa.
How can we achieve this, what changes do I need to make in configurations? Please help me with this.
Thanks,
We were able to call C# web form pages from VB.NET Web Form.
For doing so, in the C# web form project build events property. We wrote some command line
Then added that project as a reference in main vb project. This let me call the pages.

Writing Control in Windows phone

I am trying to create a new Control (Let us for now forget about UserControl or CustomControl).
I open a Windows phone Application project in vs2010 and then add a new item Windows phone Control Library and then I use it in my phone application.
Everything works fine. Now if I want to create a windows phone control to be used in another application how should I be going about it? New application means a separate new solution.
Phone Application1 -> Have my own control inside the solution and hence I am able to use it.
How can I use this same control in another new solution?
I am not sure if this has been answered before. Does any solution already exist?
Cavet:
I tried creating a new Windows phone Class Library in a vs2010 instance but it didn't work because it didn't had a xaml form. When I tried to manually include it and write the logic it build successfully but now even if I include the dll of this project I don't get the control in the toolbox. This process does not make much sense to me as I am creating a class library and not a control but still wanted to give it a try.
To show controls from your assembly in the toolbox, you should do design-time assembly. You can look at these articles for the beginning:
Link2
Link1
It's not easy and perhaps you can live without that if your control assembly is not a commercial product. To use any control from other assembly in application:
add project reference to your control assembly
include xmlns namespace attribute corresponding to your assembly to any page of your application. Just start typing 'xmlns=' near other xmlns definitions in the page header and VS intellisense will show you the list of available namespaces. Choose the needed one and then set namespace alias to use on the page. It should look something like xmlns:myNamespace="clr-namespace:MyAssembly.Namespace.;assembly=MyAssembly"
insert control from your assembly into page using xaml editor
now you should be able to see your control in xaml designer and edit its properties from the property grid
.
I am not sure if the above mentioned method would solve the case, because as far as I have seen it is not possible to create a Windows Phone Control Library in VS2010. So this is what I did..
Created a Windows Phone Control Library and write my own custom control.
Build the project.
Back to Vs2010, added the reference to the control in the app in which I wish to use.
As simple as that. I don't know why it was initially a little bit confusing (perhaps I would have got confused with the binding and stuff). Anyways its quite simple though. Thank you for the reply.

Asp.net user control changing language on texts

I'm working on a asp.net website and I have created a user control where I've placed a menu to be used on the master page. Now I want to be able to change the language on each menu item by using a resource file. How do I change this on a user control? I've worked it out on a regular aspx-page but ascx workes different as it derives from System.Web.UI.UserControl.
How did you do it on the aspx page? You can go into design mode, select generate local resources and the resx file will be generated for you. For User Controls it works the same way as for ASP.NET web forms.

ASP.NET - How do I package a Web User Control (.ascx) in a DLL for use in other applications?

I have developed a paging control that I would like to use in a variety of applications, both C# and VB.NET.
I'd like to package the entire thing, markup and all, into a DLL which I can add as a reference from my other applications' bin folders.
If this is not possible, or is a very bad idea, what is the recommended method for deploying a web user control amongst multiple applications?
(I like how easy it is to utilize Ajax Toolkit controls from a single DLL, although I'm not sure if those are custom controls or web user controls)
Thanks
Just in case you still interested I paste a link to a codeproject article where you have a interesting option for creating a user control library. I implemented it for a project a worked very well.
Here is the link
http://www.codeproject.com/KB/user-controls/EmbeddedUserControl.aspx

C# web forms api to dynamically create forms

I am working on an asp.net project which has numerous form screens. All our forms are pretty much using a given set layout which needs to be made by developers ond an on again.
Our current implementation requires that for every form control, a developers needs to write inside in the .aspx file the HTML of our forms (whilst embedding our field controls in them).
As a result, we have our project's HTML code scattered in many, many controls all over the place. It is highly possible that we change the HTML of our forms in the future.
Does asp.net C# have anything similar to Drupal's Form API which allows developers to simply create their forms programatically using a "Form Control" of some sort? The developer would add 'rows' with different field controls in them. It is then upto the 'Form Control' to generate the HTML structure of the form in the end.
Using such a method should give me the following benefits:
HTML is all in one place - making it easy to change and even skin differently
Developers who are not HTML+CSS savvy do not need to tinker out of their comfort zone
Fast development of new forms
I had a look online and it looks to me that maybe what I am after is a Hybrid Table Control that is modified to generate Div's (and not necessarily table tags).
Any ideas?
I would:
create a master page for the whole web application
create a nested master page for the pages where these data controls appear
put all necessary CSS, html etc in these master pages
create a 'template control' for developers to follow, where they just need to drop items onto a new control.

Categories

Resources