.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 7th, 2004, 02:38 AM
bitethebytes bitethebytes is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 4 bitethebytes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Custom Server Control via XML

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



Reply With Quote
  #2  
Old May 7th, 2004, 05:26 AM
bitethebytes bitethebytes is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 4 bitethebytes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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...

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Custom Server Control via XML


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT