|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi there,
I have the following problem: I read the following article ( that is not the real problem ):http://www.devarticles.com/c/a/ASP.NET/Creating-Dynamic-ASP.NET-Server-Controls-Using-XML/ In this article is discriped how to dynamicly gererate Server controls using xml. If i work like discriped in the article then it works fine: You have to define in an xml-file what kind of controls you want to use in your asp.net site. Then you'll have to write an xslt-script that transforms these xml-definitions into asp-tags. This works by using Page.Parsecontrol and then add the parsed control to an ASP:Placeholder. Later on there is another function to process the created controls when the form is submitted. This works by using the FindControl function and putting the by the ID found control into an simple object. Then it is tested if the object (controls) -type is an TextBox or an RadionButton or something like that. Each control type has its own treatment (dont know if this is the right word for it ???(bad english)). Sooo this would by all ok, if i just want to use normal asp-tags. But i want to use my own custom controls. (example: Label, Textbox (or Dropdown, or Listbox, or ...),validator) So if the xml transformer function wants to parse the controls i become an error message: Parser-Fehlermeldung: Unbekanntes Servertag: 'kocs:ValidTextBox' (Parser-ErrorMessage: Unknown Servertag: ) The Server-tag is the tag i want to use for my own custom server-control. Question: Does anybody know if it is possible to use (or how to use) custom server controls in the way i want to use them ? (dynamicly generated using xml) (in my aspx-file i registered the assembly of the controls an the tagsprefix (kocs)) How can i tell the parser that this tag is an custom server control tag. Or how can i generate (initialize) these custom server controls in an other way to the form? Another thing is, that if i define my custom controls in the aspx file myself and not let them be generated , how can i get access to to controls later on, if i dont define the in the code-behind-site as an variable ? I'll need this because i want to develope an application that can manage different kind of "Messages". (Example: Someone wants to handle Defect-Messages (for bug-tracking) and ToDo's. Someone else wants to handle Change-Requests and ToDos and Defect Messages. .... To do so you'll have to define these messages in an xml-File. From this xml-File an transformer builds the database-tables and the code-behind-transformer should dynamicly generate the needed forms. Can someone help me out of this? (I am not an professional asp.net developer) Maybe the are other ways to realize the application, that i havent noticed till now... hmmmm. would be great to get an hint or something like that. Thanx |
|
#2
|
|||
|
|||
|
maybe i figured it out myself...
I have tried something like this:
(I work with an XML-File, but should be the same...) XPathDocument xpdocControlsDoc = new XPathDocument( Server.MapPath( "YourXML.xml" ) ); XslTransform xsltTransform = new XslTransform(); xsltTransform.Load( Server.MapPath( "YourXSTL.xslt" ) ); StringWriter sw = new StringWriter(); xsltTransform.Transform( xpdocControlsDoc, null, sw, null); string result = "<%@ Register TagPrefix=\"YourPrefix\" Namespace=\"YourNamespace\" Assembly=\"YourAssembly\" %>"; result += sw.ToString(); Now (with the register in front of the string) i could parse the string without error message. Control ctrl = ParseControl( result ); and then add the Control to the placeholder aspphContainer.Controls.Add( ctrl ); I hope that this is what you wanted to know ? I'll have to try with it for myself a little bit. I am also in the need to dynamicly generate forms out of XML. Normaly no problem if i just work with standard asp-tags but with my own custom server controls... |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > Custom Server Control via XML |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|