CodeVerge.Net Beta


   Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > Asp.Net Forum > microsoft_downloads.css_friendly_control_adapters Tags:
Item Type: Date Entered: 6/15/2006 8:59:18 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 2 Views: 51 Favorited: 0 Favorite
3 Items, 1 Pages 1 |< << Go >> >|
"Khun Jean" <>
NewsGroup User
I need an example of an adapter for an asp:image control6/15/2006 8:59:18 PM

0

I am trying to understand this adapter thing but have some difficulties. :)

Can anyone give me an example on how to make an adapter for an asp:image control.

I have seen the adapters for the menu and it looks great. I even understand how it works, but cannot 'translate' this to a simple control like asp:image.

I am particularly interested in this as i want to have my own control over the properties of a control.

Thanx in advance.

Jean

 

"Russ Helfand"
NewsGroup User
Re: I need an example of an adapter for an asp:image control6/16/2006 3:13:11 AM

0

Here a C# version of something I cranked out without testing... so good luck!

using System;
using System.Data;
using System.Collections;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace YourNameHere
{
    public class ImageAdapter : System.Web.UI.WebControls.Adapters.WebControlAdapter
    {
        public DataListAdapter()
        {
        }

        /// ///////////////////////////////////////////////////////////////////////////////
        /// PROTECTED       
       
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            RegisterScripts();
        }

        protected override void RenderBeginTag(HtmlTextWriter writer)
        {
            if ((Control != null) && (Control.Attributes["CssSelectorClass"] != null) && (Control.Attributes["CssSelectorClass"].Length > 0))
            {
                writer.WriteLine();
                writer.WriteBeginTag("span");
                writer.WriteAttribute("class", Control.Attributes["CssSelectorClass"]);
                writer.Write(HtmlTextWriter.TagRightChar);
                writer.Indent++;
            }

            writer.WriteLine();
            writer.WriteBeginTag("span");
            writer.WriteAttribute("class", "YourNameHere-Image");
            writer.Write(HtmlTextWriter.TagRightChar);           
        }

        protected override void RenderEndTag(HtmlTextWriter writer)
        {
            writer.WriteEndTag("span");

            if ((Control != null) && (Control.Attributes["CssSelectorClass"] != null) && (Control.Attributes["CssSelectorClass"].Length > 0))
            {
                writer.Indent--;
                writer.WriteLine();
                writer.WriteEndTag("span");
            }

            writer.WriteLine();
        }

        protected override void RenderContents(HtmlTextWriter writer)
        {
            Image image = Control as Image;
            if (image != null)
            {
                writer.Indent++;

                writer.WriteBeginTag("img");
                writer.WriteAttribute("src", Page.ResolveUrl(image.ImageUrl));
                writer.WriteAttribute("alt", image.ToolTip);
                writer.Write(HtmlTextWriter.SelfClosingTagEnd);

                writer.Indent--;
                writer.WriteLine();
            }
        }

        /// ///////////////////////////////////////////////////////////////////////////////
        /// PRIVATE       

        private void RegisterScripts()
        {
        }
    }
}

In your .browser file you would need to add elements like these:

<adapter controlType="System.Web.UI.WebControls.Image" adapterType="YourNameHere.ImageAdapter" />

Then you would want to start customizing the code you find in RenderContents. Make sense?


Russ Helfand
Groovybits.com
"Khun Jean" <>
NewsGroup User
Re: I need an example of an adapter for an asp:image control6/16/2006 2:03:49 PM

0

Thanks a lot!

Yes it makes sense.

The reason i need this is that i have to change the src tag of each image. I have no access to the source of the website so this is ideal solution to adapt the rendering of every asp:image.

 

3 Items, 1 Pages 1 |< << Go >> >|


Free Download:













regarding image control

asp.net vs. isapi or???

to open a web form...

weird looking url - just curious

i can't create new asp.net web application.

website templates

problem with creating new method to the dal

vwd 2008 licensing woes

httpmodules do nothing

file upload and directory structure

making treeview open in iframes

need help on events in asp.net runtime control

postback is null

what does contextutil.setabort() do?

create pages on the fly using ihttphandler. need advice

query works in access but not for gridview.

byte array from flex2(flash) to asp.net to hd woot!

reading of textfields within a form

recommendation: retrieving url variable

the name 'fileupload1' does not exist in the current context

need tutorials/book on asp

open/save dialog box detection

dropdownlist conserve value

fckeditor ...reload..anynone help????

how to get the last word in directory name

which control to use?

database connectivity

running sub routine after page has loaded

mail from localhost

cookies vs. session?

iis 7.0 and ftp 7

meta tags and title of a web pages

in asp.net 2.0, how to compile a project to a custom named assembly?

online store

publish asp.net 2 web site with sqlexpress in app_data

calendar control

why are these fonts so small?

application_error not fireing with unhandled error, but does use configured redirect page

.net certification

need help getting started....

client side debugging problem

url rewriting

video tutorial doesn't work for me?!

single point entry systems

try to make a youtube clone

user logoff/running applications

simple view record form

how to create reports in dot net 2003 ?

formatting a gridview control

detect cookies

   
  Privacy | Contact Us
All Times Are GMT