Search
Re: Control Adapters
Started by leblanc at 01-09-2008 1:44 PM. Topic has 3 replies.

Print Search « Previous Thread Next Thread »
  01-09-2008, 1:44 PM
leblanc is not online. Last active: 6/2/2008 5:51:51 PM leblanc

Top 10 Posts
Joined on 01-07-2008
Posts 15
Control Adapters
Reply Quote

One of the biggest problems i had with asp.net is it didn't seperate control properties from its visual appearance.
control adapters fixed this by using a visitor pattern which contains logic on how the control renders itself.
although i understand the theory i've never done it.  Is anyone designing using control adapters?

here are practical problems:
1) <form action="" method="post">
rewriting the action attribute.  See i'm using apache to proxy an asp.net site so that apache handles all the rewrite rules. provides ssl - with openssl.  support for wildcard.domain.com.  Currently i have javascript rewriting it.. but i would like to hardcode the value on the server side.

2) highlight text from search engines.  this is simple in php as i start ob_start hold my buffer and get the final string value when the page is finished processing... then i just run a regex to replace text with a highlighted version.  In asp.net things fire differently and holding the buffer doesn't aways work.  If i can generate a control adapter containing this logic.. i could pass it to the page class which renders the page... or at least to my master page content panels.


   Report 
  02-13-2008, 11:01 PM
leblanc is not online. Last active: 6/2/2008 5:51:51 PM leblanc

Top 10 Posts
Joined on 01-07-2008
Posts 15
Re: Control Adapters
Reply Quote
Answer to #1:
<font face="Lucida Console" size="2">
namespace RobustHaven.KnowledgeBase
{
public class Form : System.Web.UI.HtmlControls.HtmlForm
{
public Form():base()
{
}
protected override void RenderAttributes(HtmlTextWriter writer)
{
writer.WriteAttribute(&quot;id&quot;, this.ID);
writer.WriteAttribute(&quot;method&quot;, this.Method);
writer.WriteAttribute(&quot;action&quot;, &quot;&quot;);
}
}
}
</font>

by default the browser will post back to the same url as in the url bar.
<font face="Lucida Console" size="2">
&lt;pages&gt;
&lt;tagMapping&gt;
&lt;add tagType=&quot;System.Web.UI.HtmlControls.HtmlForm&quot;
mappedTagType=&quot;RobustHaven.KnowledgeBase.Form&quot;/&gt;
&lt;/tagMapping&gt;
&lt;/pages&gt;

</font>
   Report 
  02-13-2008, 11:50 PM
leblanc is not online. Last active: 6/2/2008 5:51:51 PM leblanc

Top 10 Posts
Joined on 01-07-2008
Posts 15
Re: Control Adapters
Reply Quote
answer to #2

since i don't know how to add code to this forum... i posted the code on nopaste.

http://rafb.net/p/W0hYNW59.html

the idea is to replace the default contentplaceholder in a master page with my custom version which sends in the custom htmltextwriter which will add highlighting and remove duplicate spacing [don't forget to skip pre tag content].
   Report 
  02-15-2008, 8:49 AM
tbarcz is not online. Last active: 8/10/2008 6:51:02 PM tbarcz

Top 10 Posts
Joined on 06-22-2005
Posts 44
Re: Control Adapters
Reply Quote
 I can't explain entirely how it all works, but I do know that in one version of our product we had implemented one of the control adapters for the sole purpose of controlling the HTML markup emitted from controls in order to have accessible HTML markup.  In our industry (health-care) accessibility becomes important, and therefore had wanted to use some of the out-of-the-box controls like the LoginForm but needed to make them accessible, we used control adapters.

If you want me to, I can look at what we did for some specific answers if you still have them.

Tim

   Report 
Post
CRINETA » .NET Discussion... » General .NET Di... » Re: Control Adapters

Copyright Cedar Rapids INETA, 2005 All rights reserved.

Powered by Community Server, by Telligent Systems