Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > HTML <SELECT><OPTION> Tag With Image and Text

Reply
Thread Tools

HTML <SELECT><OPTION> Tag With Image and Text

 
 
=?Utf-8?B?Q2hyaXMgRmluaw==?=
Guest
Posts: n/a
 
      12-28-2004
Does anyone know it is possible to include a small image(.gif .jpeg)
within a <SELECT><option> so that the user would see the option text as
well as a little image(icon) in the option? I know this is not an ASP.NET
related question, but I know this group is knowledgeable and quick with
responses.

Thanks



 
Reply With Quote
 
 
 
 
Curt_C [MVP]
Guest
Posts: n/a
 
      12-28-2004
no... not with the standard SELECT control.
You will need a custom one for that.

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com


"Chris Fink" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Does anyone know it is possible to include a small image(.gif .jpeg)
> within a <SELECT><option> so that the user would see the option text as
> well as a little image(icon) in the option? I know this is not an ASP.NET
> related question, but I know this group is knowledgeable and quick with
> responses.
>
> Thanks
>
>
>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q2hyaXMgRmluaw==?=
Guest
Posts: n/a
 
      12-28-2004
I understand how to make ASP.NET compiled controls but may need a few
pointers to get started on creating this from scratch. Is there a base
control that I can use to start this or do I have to graphically create this
from scratch? Just some design ideas will be a good start and I should be
able to take it from there.

Thanks
"Curt_C [MVP]" wrote:

> no... not with the standard SELECT control.
> You will need a custom one for that.
>
> --
> Curt Christianson
> Owner/Lead Developer, DF-Software
> Site: http://www.Darkfalz.com
> Blog: http://blog.Darkfalz.com
>
>
> "Chris Fink" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Does anyone know it is possible to include a small image(.gif .jpeg)
> > within a <SELECT><option> so that the user would see the option text as
> > well as a little image(icon) in the option? I know this is not an ASP.NET
> > related question, but I know this group is knowledgeable and quick with
> > responses.
> >
> > Thanks
> >
> >
> >

>
>
>

 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      12-29-2004
as most of the work will be the javascript code, create the flyout menu,
handle mouse and keyboard events, display selection, postback data, a good
javascript book is your first task. once you have the javascript worked out,
the control is pretty simple, look at any example. as you will probably use
a hidden field for the postback, you could inherit from the HtmlInputHidden
control, and override the OnRender method.

-- bruce (sqlwork.com)



"Chris Fink" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
| I understand how to make ASP.NET compiled controls but may need a few
| pointers to get started on creating this from scratch. Is there a base
| control that I can use to start this or do I have to graphically create
this
| from scratch? Just some design ideas will be a good start and I should be
| able to take it from there.
|
| Thanks
| "Curt_C [MVP]" wrote:
|
| > no... not with the standard SELECT control.
| > You will need a custom one for that.
| >
| > --
| > Curt Christianson
| > Owner/Lead Developer, DF-Software
| > Site: http://www.Darkfalz.com
| > Blog: http://blog.Darkfalz.com
| >
| >
| > "Chris Fink" <(E-Mail Removed)> wrote in message
| > news:(E-Mail Removed)...
| > > Does anyone know it is possible to include a small image(.gif .jpeg)
| > > within a <SELECT><option> so that the user would see the option text
as
| > > well as a little image(icon) in the option? I know this is not an
ASP.NET
| > > related question, but I know this group is knowledgeable and quick
with
| > > responses.
| > >
| > > Thanks
| > >
| > >
| > >
| >
| >
| >


 
Reply With Quote
 
Ken Dopierala Jr.
Guest
Posts: n/a
 
      12-29-2004
Hi Chris,

This was a cool question! I don't know if someone has put a 3rd party
control out there like this yet. My gut tells me that it is out there.
However I did some quick searches using keywords like "select", "html",
"graphic", "picture", "dropdownlist" and other keywords and combinations I
could think of but didn't come up with anything.

This could have added benefits. For example, ever notice how when you put a
div over a dropdownlist the DDL shows through so you have to hide it? Very
annoying! Might as well replace that too. To be honest, it is all of
today's browsers that need to be replaced but before I launch into my
favorite topic (which I never discuss here) I'll stop.

This is such an interesting topic though that I'm going to come up with a
solution. Curt is right, this will work best as a custom control and not
something you just want to ad hoc together everytime. Bruce is also right,
it will take javascript to get it done. I can handle the custom control and
the javascript for IE. Any javascript gurus for Opera, Mozilla, or Other
please email me because I could use your help to make this universal.
Thanks! Ken.

P.S. Chris, since this is your topic, what would you like? Are you looking
for a few preset graphic sizes or do you want to specify? Do you want to be
able to use html to display the text in the list (bold, multiline items,
specify the color of each item, more than one column, etc.)? Would you be
interested in having items in the list that can in turn be themselves
dropdowns? What about nested dropdowns that go back to the server and fill
themselves with data based on a function you supply without performing a
postback? Sky's the limit. All I can say is this is going to be a blast!

P.P.S. Thanks for the post!

"Chris Fink" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Does anyone know it is possible to include a small image(.gif .jpeg)
> within a <SELECT><option> so that the user would see the option text as
> well as a little image(icon) in the option? I know this is not an ASP.NET
> related question, but I know this group is knowledgeable and quick with
> responses.
>
> Thanks
>
>
>



 
Reply With Quote
 
=?Utf-8?B?Q2hyaXMgRmluaw==?=
Guest
Posts: n/a
 
      12-29-2004
Thanks for all the feedback. Over the past few weeks, this idea started as a
simple tooltip on a webpage and has now evolved into a much more functional
version....

What I invision is the ability to hover over an object on a webpage and have
an "intellisense" like dropdownlist (just like in visual studio) appear below
that object. The collection in the intellisense list would have icons
associated with each item and when the user selects an item it will redirect
the user to a new page/window. When the user hover's off this object, the
intellisense dropdown will disappear. I feel this is a robust way to make
use of a web page's space and to also add much needed functionality to a
website.

Ken - I would like to see your finished product and any other
idea's/comments you may have. This would also be an opportune time to
cooperate and share some of the development work....

To share some of my work, I have started to develop a rudimentary custom
control that uses the select option html tag and some javascript to hide and
unhide the object when a user mouseover's an object on the form. Since the
select option tag will not accomplish all of the goals of the design, most of
this code will not be extendable.

Please be in touch!
Chris

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Collections;
using System.Collections.Specialized;

namespace Applications.Library.Controls
{
[DefaultProperty("Text"),
ToolboxData("<{0}:Intellisense runat=server></{0}:Intellisense>")]
public class Intellisense : WebControl
{
private string text;

[Bindable(true),
Category("Appearance"),
DefaultValue("")]
public string Text
{
get
{
return text;
}

set
{
text = value;
}
}


[
Bindable(true),
Category("Data"),
Description("HTML Select Box Collection")
]
private StringCollection _selectItems ;
public StringCollection SelectItems
{
get { return _selectItems;}
set{_selectItems = value;}
}

[
Bindable(true),
Category("Data"),
Description("HTML Select Box Collection")
]
private int _htmlSelectTagSize = 4;
public int HtmlSelectTagSize
{
get { return _htmlSelectTagSize;}
set{_htmlSelectTagSize = value;}
}

private string WriteJSScript()
{
// should provide alternative if browser can't js
return ("<script type=\"text/javascript\">function
show(elmnt){document.all(elmnt).style.visibility=\ "visible\"} function
hide(elmnt){document.all(elmnt).style.visibility=\ "hidden\"}</script>");
}

private string WriteCSScript()
{
return
"<style>body{font-family:arial;}table.menu{font-size:100%;position:absolute;visibility:hidden;}</style>";
}

protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
Page.RegisterClientScriptBlock("jsBlock",WriteJSSc ript());
Page.RegisterClientScriptBlock("cssBlock",WriteCSS cript());

}

protected override void Render(HtmlTextWriter output)
{

// write html around selectbox
output.Write("<table><tr><td onmouseover=\"show('{0}')\"
onmouseout=\"hide('{0}')\">HoverObject<table
class=\"menu\"><tr><td>",this.ClientID.ToString()) ;

// try to render html listbox / textarea
output.AddAttribute(HtmlTextWriterAttribute.Name, "optSelect");
output.AddAttribute(HtmlTextWriterAttribute.Id,thi s.ClientID.ToString())
output.AddAttribute(HtmlTextWriterAttribute.Size,_ htmlSelectTagSize.ToString());
output.RenderBeginTag(HtmlTextWriterTag.Select);

// Goal is to loop through SelectItems which is type StringCollection
// StringCollection class implements IEnumerable Interface
if (SelectItems !=null)
{
System.Collections.IEnumerator myEnumerator =
((IEnumerable)SelectItems).GetEnumerator();
while ( myEnumerator.MoveNext() )
{
output.RenderBeginTag(HtmlTextWriterTag.Option)
output.AddAttribute(HtmlTextWriterAttribute.Value, myEnumerator.Current.ToString());
output.Write(myEnumerator.Current.ToString());
}
}

output.Write("</select>");
output.Write("</td></tr></table></td></tr></table>");

}
}
}






"Ken Dopierala Jr." wrote:

> Hi Chris,
>
> This was a cool question! I don't know if someone has put a 3rd party
> control out there like this yet. My gut tells me that it is out there.
> However I did some quick searches using keywords like "select", "html",
> "graphic", "picture", "dropdownlist" and other keywords and combinations I
> could think of but didn't come up with anything.
>
> This could have added benefits. For example, ever notice how when you put a
> div over a dropdownlist the DDL shows through so you have to hide it? Very
> annoying! Might as well replace that too. To be honest, it is all of
> today's browsers that need to be replaced but before I launch into my
> favorite topic (which I never discuss here) I'll stop.
>
> This is such an interesting topic though that I'm going to come up with a
> solution. Curt is right, this will work best as a custom control and not
> something you just want to ad hoc together everytime. Bruce is also right,
> it will take javascript to get it done. I can handle the custom control and
> the javascript for IE. Any javascript gurus for Opera, Mozilla, or Other
> please email me because I could use your help to make this universal.
> Thanks! Ken.
>
> P.S. Chris, since this is your topic, what would you like? Are you looking
> for a few preset graphic sizes or do you want to specify? Do you want to be
> able to use html to display the text in the list (bold, multiline items,
> specify the color of each item, more than one column, etc.)? Would you be
> interested in having items in the list that can in turn be themselves
> dropdowns? What about nested dropdowns that go back to the server and fill
> themselves with data based on a function you supply without performing a
> postback? Sky's the limit. All I can say is this is going to be a blast!
>
> P.P.S. Thanks for the post!
>
> "Chris Fink" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Does anyone know it is possible to include a small image(.gif .jpeg)
> > within a <SELECT><option> so that the user would see the option text as
> > well as a little image(icon) in the option? I know this is not an ASP.NET
> > related question, but I know this group is knowledgeable and quick with
> > responses.
> >
> > Thanks
> >
> >
> >

>
>
>

 
Reply With Quote
 
Ken Dopierala Jr.
Guest
Posts: n/a
 
      12-30-2004
Hi Chris,

I'm going to be working on this shortly. I just started a company (which
lanuches 1/1/2005) and I'm making this the top thing on the ToDo:. I think
this control could be awesome. Use my email to contact me about code. Ken.

"Chris Fink" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks for all the feedback. Over the past few weeks, this idea started

as a
> simple tooltip on a webpage and has now evolved into a much more

functional
> version....
>
> What I invision is the ability to hover over an object on a webpage and

have
> an "intellisense" like dropdownlist (just like in visual studio) appear

below
> that object. The collection in the intellisense list would have icons
> associated with each item and when the user selects an item it will

redirect
> the user to a new page/window. When the user hover's off this object, the
> intellisense dropdown will disappear. I feel this is a robust way to make
> use of a web page's space and to also add much needed functionality to a
> website.
>
> Ken - I would like to see your finished product and any other
> idea's/comments you may have. This would also be an opportune time to
> cooperate and share some of the development work....
>
> To share some of my work, I have started to develop a rudimentary custom
> control that uses the select option html tag and some javascript to hide

and
> unhide the object when a user mouseover's an object on the form. Since

the
> select option tag will not accomplish all of the goals of the design, most

of
> this code will not be extendable.
>
> Please be in touch!
> Chris
>
> using System;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.ComponentModel;
> using System.Collections;
> using System.Collections.Specialized;
>
> namespace Applications.Library.Controls
> {
> [DefaultProperty("Text"),
> ToolboxData("<{0}:Intellisense runat=server></{0}:Intellisense>")]
> public class Intellisense : WebControl
> {
> private string text;
>
> [Bindable(true),
> Category("Appearance"),
> DefaultValue("")]
> public string Text
> {
> get
> {
> return text;
> }
>
> set
> {
> text = value;
> }
> }
>
>
> [
> Bindable(true),
> Category("Data"),
> Description("HTML Select Box Collection")
> ]
> private StringCollection _selectItems ;
> public StringCollection SelectItems
> {
> get { return _selectItems;}
> set{_selectItems = value;}
> }
>
> [
> Bindable(true),
> Category("Data"),
> Description("HTML Select Box Collection")
> ]
> private int _htmlSelectTagSize = 4;
> public int HtmlSelectTagSize
> {
> get { return _htmlSelectTagSize;}
> set{_htmlSelectTagSize = value;}
> }
>
> private string WriteJSScript()
> {
> // should provide alternative if browser can't js
> return ("<script type=\"text/javascript\">function
> show(elmnt){document.all(elmnt).style.visibility=\ "visible\"} function
> hide(elmnt){document.all(elmnt).style.visibility=\ "hidden\"}</script>");
> }
>
> private string WriteCSScript()
> {
> return
>

"<style>body{font-family:arial;}table.menu{font-size:100%;position:absolute;
visibility:hidden;}</style>";
> }
>
> protected override void OnPreRender(EventArgs e)
> {
> base.OnPreRender(e);
> Page.RegisterClientScriptBlock("jsBlock",WriteJSSc ript());
> Page.RegisterClientScriptBlock("cssBlock",WriteCSS cript());
>
> }
>
> protected override void Render(HtmlTextWriter output)
> {
>
> // write html around selectbox
> output.Write("<table><tr><td onmouseover=\"show('{0}')\"
> onmouseout=\"hide('{0}')\">HoverObject<table
> class=\"menu\"><tr><td>",this.ClientID.ToString()) ;
>
> // try to render html listbox / textarea
> output.AddAttribute(HtmlTextWriterAttribute.Name, "optSelect");
> output.AddAttribute(HtmlTextWriterAttribute.Id,thi s.ClientID.ToString());
>

output.AddAttribute(HtmlTextWriterAttribute.Size,_ htmlSelectTagSize.ToString
());
> output.RenderBeginTag(HtmlTextWriterTag.Select);
>
> // Goal is to loop through SelectItems which is type StringCollection
> // StringCollection class implements IEnumerable Interface
> if (SelectItems !=null)
> {
> System.Collections.IEnumerator myEnumerator =
> ((IEnumerable)SelectItems).GetEnumerator();
> while ( myEnumerator.MoveNext() )
> {
> output.RenderBeginTag(HtmlTextWriterTag.Option);
>

output.AddAttribute(HtmlTextWriterAttribute.Value, myEnumerator.Current.ToStr
ing());
> output.Write(myEnumerator.Current.ToString());
> }
> }
>
> output.Write("</select>");
> output.Write("</td></tr></table></td></tr></table>");
>
> }
> }
> }
>
>
>
>
>
>
> "Ken Dopierala Jr." wrote:
>
> > Hi Chris,
> >
> > This was a cool question! I don't know if someone has put a 3rd party
> > control out there like this yet. My gut tells me that it is out there.
> > However I did some quick searches using keywords like "select", "html",
> > "graphic", "picture", "dropdownlist" and other keywords and combinations

I
> > could think of but didn't come up with anything.
> >
> > This could have added benefits. For example, ever notice how when you

put a
> > div over a dropdownlist the DDL shows through so you have to hide it?

Very
> > annoying! Might as well replace that too. To be honest, it is all of
> > today's browsers that need to be replaced but before I launch into my
> > favorite topic (which I never discuss here) I'll stop.
> >
> > This is such an interesting topic though that I'm going to come up with

a
> > solution. Curt is right, this will work best as a custom control and

not
> > something you just want to ad hoc together everytime. Bruce is also

right,
> > it will take javascript to get it done. I can handle the custom control

and
> > the javascript for IE. Any javascript gurus for Opera, Mozilla, or

Other
> > please email me because I could use your help to make this universal.
> > Thanks! Ken.
> >
> > P.S. Chris, since this is your topic, what would you like? Are you

looking
> > for a few preset graphic sizes or do you want to specify? Do you want

to be
> > able to use html to display the text in the list (bold, multiline items,
> > specify the color of each item, more than one column, etc.)? Would you

be
> > interested in having items in the list that can in turn be themselves
> > dropdowns? What about nested dropdowns that go back to the server and

fill
> > themselves with data based on a function you supply without performing a
> > postback? Sky's the limit. All I can say is this is going to be a

blast!
> >
> > P.P.S. Thanks for the post!
> >
> > "Chris Fink" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Does anyone know it is possible to include a small image(.gif .jpeg)
> > > within a <SELECT><option> so that the user would see the option text

as
> > > well as a little image(icon) in the option? I know this is not an

ASP.NET
> > > related question, but I know this group is knowledgeable and quick

with
> > > responses.
> > >
> > > Thanks
> > >
> > >
> > >

> >
> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find <tag> to </tag> HTML strings and 'save' them? mark@agtechnical.co.uk Python 7 03-26-2007 04:11 PM
HTML.Tag.BASE same as HTML.Tag.A carlbernardi@gmail.com Java 1 11-29-2006 03:41 AM
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
How to get the text in html tag.like<div...><font...>Text</font></ =?Utf-8?B?Tmlja3k=?= ASP .Net 2 02-20-2005 03:03 PM
Select text within a div tag by clicking on content of div tag? M Wells Javascript 0 10-06-2004 11:04 AM



Advertisments