asp.net - How to build ImageButton Control Adapter (or more general, how to build a simple control adapter)? -
My inspiration for this question is very annoying at default style ( border-width: 0px;
) Click. The simplest solution is to override it by adding your style to control. style = "border-width: 2px;"
.
How, it would be good to create just a simple control adapter, which will only step in the right place and tell the controls to not just render the default style.
After looking at the code from the CSSFriendly ControlAdapter project, it seems that they are rendering too much, which is what I want to do or just change the default style which is Is provided.
So the question, how to modify the rendering of default styles just by default adapters, and leaving the rest?
Is this possible?
Thank you, Egil.
Two ways of doing this will both need to be written as a custom control adapter or you are actually in the code You can set the value, or you can not include the value at all and then use CSS to set your value. You need to do this code.
Namespace TestApp {system.IO; Using System.Web.UI; Using System.Web.UI.Adapters; Public Class ImageAdapter: ControlledEditor {Providing Safe Override Zero (HtmlTextWriter Writer) {base.Render (New Reverted Image HTML Text Writer (Author)); } Public Class Rewrite Image HTML Reader: HTMLextraire {Public Revert Image HTML Reader Writer (Text Writer): Support (Author) {Inwriter = Author; } Public Revert Image HTML Texturator (HTMT Reader Writer): Base (Author) {Innerwriter = Writer.In-Viator; } Public override zero AddAttribute (HtmlTextWriterAttribute key, string value, bool fEncode) {if (key == HtmlTextWriterAttribute.Border) {// value // value = "2"; Value / refund is not included in // -or- //; } Base.AddAttribute (Key, Value, FEncode); } Public override zero AddStyleAttribute (HtmlTextWriterStyle key, string value) {if (key == HtmlTextWriterStyle.BorderWidth) {// Change value // value = "2px"; Value / refund is not included in // -or- //; } Base.AddStyleAttribute (key, value); }}}}
You will then need to add the entry to one of your browser files
& lt; Browser & gt; & Lt; Browser refID = "Default" & gt; & Lt; ControlAdapters & gt; & Lt; Adapter controlType = "System.Web.UI.WebControls.Image" type adapter = "TestApp.ImageAdapter, TestApp" /> & Lt; / ControlAdapters & gt; & Lt; / Browser & gt; & Lt; / Browsers & gt;
Comments
Post a Comment