<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Ajax</title>
        <link>http://geekswithblogs.net/chrishan/category/6465.aspx</link>
        <description>Asp.net Ajax Extensions and Ajax Control ToolKit</description>
        <language>en-US</language>
        <copyright>Chris Han</copyright>
        <managingEditor>chrishan2000@hotmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>The position problem with ListSearch control in Ajax ControlTool Kit</title>
            <link>http://geekswithblogs.net/chrishan/archive/2007/04/02/110612.aspx</link>
            <description>&lt;P&gt;First of all, I'm using IE 6.0.2900.2180, Haven't test on other browsers.&lt;/P&gt;
&lt;P&gt;I was using ListSearch control to decorate my drop down lists to provide&amp;nbsp;the incremental-search ability. See the online demo here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://ajax.asp.net/ajaxtoolkit/ListSearch/ListSearch.aspx"&gt;http://ajax.asp.net/ajaxtoolkit/ListSearch/ListSearch.aspx&lt;/A&gt;&lt;A href="http://ajax.asp.net/ajaxtoolkit/"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;It all looks smooth and neat untill after I put more ajax controls to make the page more "dynamic". &amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem I was experiencing is that the promp text will not be alway located right above or under the DropDown control I specified.&amp;nbsp;(By default, the position is &lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;PositioningMode.TopLeft&lt;/FONT&gt;) T&lt;/FONT&gt;he vertical location&amp;nbsp;apear variously every time after I scroll the page! &lt;BR&gt;I looked into the tool kit source code. It seems that the ListSearch&amp;nbsp;extension internally uses the PopupExtender to create the promp text. And by default (&lt;FONT color=#0000ff size=2&gt;PositioningMode.TopLeft&lt;/FONT&gt;), PopupExtender calculate the Y position&amp;nbsp;as &lt;FONT size=2&gt;the PrompDiv's &lt;FONT color=#0000ff&gt;offsetHeight&lt;/FONT&gt; plus &lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;diff.y&lt;/FONT&gt; which is calculated by this code block:&lt;BR&gt;&lt;FONT color=#008000&gt;///////////////////////////////////////////////////////////////////////////////////////////////////////&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// offsetParent (doc element if absolutely positioned or no offsetparent available)&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;var&lt;/FONT&gt;&lt;FONT size=2&gt; offsetParent = elt.offsetParent || document.documentElement;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//alert(offsetParent.tagName); //IE is BODY if no DIV with relative postion around &lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// diff = difference in position between element's offsetParent and the element we will attach popup to.&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// this is basically so we can position the popup in the right spot even though it may not be absolutely positioned&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;var&lt;/FONT&gt;&lt;FONT size=2&gt; diff;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;var&lt;/FONT&gt;&lt;FONT size=2&gt; parentBounds;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;this&lt;/FONT&gt;&lt;FONT size=2&gt;._parentElement) {&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// we will be positioning the element against the assigned parent&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;parentBounds = CommonToolkitScripts.getBounds(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;this&lt;/FONT&gt;&lt;FONT size=2&gt;._parentElement);&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;var&lt;/FONT&gt;&lt;FONT size=2&gt; offsetParentLocation = CommonToolkitScripts.getLocation(offsetParent); &lt;BR&gt;diff = {x: parentBounds.x - offsetParentLocation.x, y:parentBounds.y - offsetParentLocation.y}; &lt;BR&gt;}&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;else&lt;/FONT&gt;&lt;FONT size=2&gt; {&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// we will be positioning the element against the offset parent by default, since no parent element given&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;parentBounds = CommonToolkitScripts.getBounds(offsetParent); &lt;BR&gt;diff = {x:0, y:0};&lt;BR&gt;}&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;&lt;BR&gt;&lt;FONT color=#008000&gt;///////////////////////////////////////////////////////////////////////////////////////////////////////&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;Notice that the first line&amp;nbsp; is to find the relative parent element in the document in order to calculate the postion of the promp?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;Realize that the offsetParent will be the "BODY" element in IE instead of &lt;FONT size=3&gt;the object which is the closest (nearest in the containment hierarchy) positioned containing element in Mozzila, I find that the way to solve this problem in IE is to:&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;&lt;FONT size=3&gt;1. Have a panel control wrap around the drop down list and your SearchList&amp;nbsp;control. &lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;&lt;FONT size=3&gt;2.&amp;nbsp;Create a stylesheet class like this:&lt;BR&gt;&lt;FONT color=#a31515 size=2&gt;&lt;STRONG&gt;.DDLPanelListSearchExtender&lt;BR&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; position&lt;/FONT&gt;&lt;FONT size=2&gt;: &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;relative&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;BR&gt;}&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;&lt;FONT size=3&gt;3. Specify&amp;nbsp;the CssClass property of the panel control you added at the first step to&amp;nbsp;this new stylesheet class &lt;STRONG&gt;DDLPanelListSearchExtender&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;You can feather use the theme to simplify this task by adding a Panel.skin which looks like this:&lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;asp&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;:&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;Panel&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;runat&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="server"&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;BorderWidth&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="0px"&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;CssClass&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="DDLPanelListSearchExtender"/&amp;gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;Happy coding!&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P.s. theoritically, this postion problem will also apear on any control that depends on PopupExtender, such as PopupControl.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=110612"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=110612" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/chrishan/aggbug/110612.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Han</dc:creator>
            <guid>http://geekswithblogs.net/chrishan/archive/2007/04/02/110612.aspx</guid>
            <pubDate>Mon, 02 Apr 2007 18:22:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/chrishan/comments/110612.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/chrishan/archive/2007/04/02/110612.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/chrishan/comments/commentRss/110612.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/chrishan/services/trackbacks/110612.aspx</trackback:ping>
        </item>
    </channel>
</rss>