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 "intellisen se" 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.W ebControls;
using System.Componen tModel;
using System.Collecti ons;
using System.Collecti ons.Specialized ;
namespace Applications.Li brary.Controls
{
[DefaultProperty ("Text"),
ToolboxData("<{ 0}:Intellisense runat=server></{0}:Intellisens e>")]
public class Intellisense : WebControl
{
private string text;
[Bindable(true),
Category("Appea rance"),
DefaultValue("" )]
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
[
Bindable(true),
Category("Data" ),
Description("HT ML Select Box Collection")
]
private StringCollectio n _selectItems ;
public StringCollectio n SelectItems
{
get { return _selectItems;}
set{_selectItem s = value;}
}
[
Bindable(true),
Category("Data" ),
Description("HT ML Select Box Collection")
]
private int _htmlSelectTagS ize = 4;
public int HtmlSelectTagSi ze
{
get { return _htmlSelectTagS ize;}
set{_htmlSelect TagSize = value;}
}
private string WriteJSScript()
{
// should provide alternative if browser can't js
return ("<script type=\"text/javascript\">fu nction
show(elmnt){doc ument.all(elmnt ).style.visibil ity=\"visible\" } function
hide(elmnt){doc ument.all(elmnt ).style.visibil ity=\"hidden\"} </script>");
}
private string WriteCSScript()
{
return
"<style>body{fo nt-family:arial;}t able.menu{font-size:100%;posit ion:absolute;vi sibility:hidden ;}</style>";
}
protected override void OnPreRender(Eve ntArgs e)
{
base.OnPreRende r(e);
Page.RegisterCl ientScriptBlock ("jsBlock",Writ eJSScript());
Page.RegisterCl ientScriptBlock ("cssBlock",Wri teCSScript());
}
protected override void Render(HtmlText Writer output)
{
// write html around selectbox
output.Write("< table><tr><td onmouseover=\"s how('{0}')\"
onmouseout=\"hi de('{0}')\">Hov erObject<table
class=\"menu\"> <tr><td>",this. ClientID.ToStri ng());
// try to render html listbox / textarea
output.AddAttri bute(HtmlTextWr iterAttribute.N ame, "optSelect" );
output.AddAttri bute(HtmlTextWr iterAttribute.I d,this.ClientID .ToString())
output.AddAttri bute(HtmlTextWr iterAttribute.S ize,_htmlSelect TagSize.ToStrin g());
output.RenderBe ginTag(HtmlText WriterTag.Selec t);
// Goal is to loop through SelectItems which is type StringCollectio n
// StringCollectio n class implements IEnumerable Interface
if (SelectItems !=null)
{
System.Collecti ons.IEnumerator myEnumerator =
((IEnumerable)S electItems).Get Enumerator();
while ( myEnumerator.Mo veNext() )
{
output.RenderBe ginTag(HtmlText WriterTag.Optio n)
output.AddAttri bute(HtmlTextWr iterAttribute.V alue,myEnumerat or.Current.ToSt ring());
output.Write(my Enumerator.Curr ent.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", "dropdownli st" 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" <Ch*******@disc ussions.microso ft.com> wrote in message
news:90******** *************** ***********@mic rosoft.com... 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