Showing posts with label below. Show all posts
Showing posts with label below. Show all posts

Saturday, March 24, 2012

DropShadowExtender

I have a masterpage with the code below.

I have a Default.aspx page that uses the masterpage.

When Rounded is set to false then I get a panel with a shadow. If i changes Rounded to true, then I get two small areas (one white and one black). What am I doing wrong.

Best regards

S?ren Agerbo Jensen.

-------

MasterPage.master:

<%@dotnet.itags.org.MasterLanguage="C#"AutoEventWireup="true"CodeFile="MasterPage.master.cs"Inherits="MasterPage" %>

<!

DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

htmlxmlns="http://www.w3.org/1999/xhtml">

<

headrunat="server"><title>FraIdeTilFaktura.dk</title>

</

head>

<

bodyalign="center"style="filter:progid:DXImageTransform.Microsoft.Gradient(endColorstr='#EEEEEE', startColorstr='#555555', gradientType='0'); padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px;"><formid="form1"runat="server"style="text-align: center;"><div><tableborder="0"cellpadding="0"cellspacing="0"style="height: 600px; width: 80%;"><tr><tdstyle="width: 100%; height: 50px;"></td></tr><tr><tdid="tekst"style="width: 100%; height: 400px;"><asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager> <ajaxToolkit:DropShadowExtenderRounded="false"ID="DropShadowExtender1"runat="server"TargetControlID="Panel1"Radius="2"TrackPosition="true"Width="5"></ajaxToolkit:DropShadowExtender><asp:PanelID="Panel1"runat="server"Height="100%"Width="100%"BackColor="White"ScrollBars="Auto"><

<

asp:ContentPlaceHolderID="ContentPlaceHolder1"runat="server"></asp:ContentPlaceHolder></asp:Panel></td></tr><tr><tdstyle="width: 100%; height: 50px;"></td></tr></table></div></form>

</

body>

<

scripttype="text/javascript">

document.getElementById(

"tekst").style.height=screen.height-300;

</

script>

</

html>

Sorry for the trouble - pleaseopen a work item to report and track this issue. Thank you!

DropShadow Resize problem with the Shadow remaining on table resize.

The code below is just a sample I added to the DropShadow and I pretty sure this is a bug.

What happens when load up is fine. When you move items from the left listbox to the right listbox it seems fine.

EXCEPT, when one listbox becomes empty, the listbox shrinks, hence the table shrinks and then your left with this big black shadow on the right that goes up to the table. That is the shadow has not resized with the table.

If I addWidth="100%" to the Panel yes it works but then my screen design is not what I want I have this massive table on the screen. It's the solution I'm forced to use now.

<divclass="demoarea">

<divclass="demoheading">DropShadow Demonstration</div><asp:PanelID="Panel1"runat="server"CssClass="dropShadowPanel"Width="100%"><divstyle="padding:10px">

<tableborder="2"width="100%">

<tr>

<tdcolspan="3"align=center> </td>

</

tr>

<

tr><td>

<asp:ListBoxRows="20"SelectionMode="Multiple"ID="lbListLeft"runat="server"><asp:ListItem>Somewhere RSL Club, 555 Something St, Somewhere</asp:ListItem><asp:ListItem>20</asp:ListItem>

<asp:ListItem>D</asp:ListItem></asp:ListBox><br/></td><td><NOBR><inputvalue="Add >>" type="button"BR></NOBR><NOBR><inputvalue="Add <<" type="button"BR></NOBR><NOBR><inputvalue="Add All >>" type="button"BR></NOBR><NOBR><inputvalue="Add All <<" type="button"BR></NOBR></td><td>

<br/><asp:ListBoxRows="20"SelectionMode="Multiple"ID="lbListRight"runat="server"><asp:ListItem> RSL Club, 154 Somewhere Pde, Somewhere</asp:ListItem><asp:ListItem>2</asp:ListItem><asp:ListItem>3</asp:ListItem>

</asp:ListBox></td>

</

tr>

</

table>

Did you set "TrackPosition='true'" on the DropShadowProperties?


Yes I haveTrackPosition="true"as it came from the example.

Here's the complete code in a master page. YOu'll notice that once you move all items to one listbox the table shrinks I have mentioned. I've done some slight changing to the html but this content page should work standalone. Unless you tweak the Content Placer then you'll have to tweak the javascript.

<%

@.PageLanguage="C#"MasterPageFile="~/Site.master"AutoEventWireup="true"CodeFile="DropShadow.aspx.cs"Inherits="DropShadow_DropShadow"Title="DropShadow Sample" %>

<%

@.RegisterAssembly="AtlasControlToolkit"Namespace="AtlasControlToolkit"TagPrefix="atlasToolkit" %>

<

asp:ContentID="Content1"ContentPlaceHolderID="MiddleContent"Runat="Server"><atlas:ScriptManagerid="ScriptManager"EnablePartialRendering="true"runat="Server"/><divclass="demoarea"><asp:PanelID="Panel1"runat="server"CssClass="dropShadowPanel"><divstyle="padding:10px">

<

tableborder="0"width="100%">

<tr><td><tableborder=0width="100%">

<tr><tdalign="right"><asp:ListBoxRows="20"SelectionMode="Multiple"ID="lbListLeft"runat="server"><asp:ListItem>Kogarah RSL Club, 254 Railway Pde, Kogarah</asp:ListItem><asp:ListItem>20</asp:ListItem><asp:ListItem>30</asp:ListItem><asp:ListItem>40</asp:ListItem><asp:ListItem>A</asp:ListItem><asp:ListItem>B</asp:ListItem><asp:ListItem>C</asp:ListItem><asp:ListItem>D</asp:ListItem></asp:ListBox></td></tr></table><br/><br/></td><td><NOBR><inputvalue="Add >>"onclick="moveDualList( this.form.ctl00$MiddleContent$lbListLeft, this.form.ctl00$MiddleContent$lbListRight, false );"type="button"style="width:90"><BR></NOBR><NOBR><inputvalue="Add <<"onclick="moveDualList( this.form.ctl00$MiddleContent$lbListRight, this.form.ctl00$MiddleContent$lbListLeft, false );"type="button"style="width:90"><BR></NOBR><NOBR><inputvalue="Add All >>"onclick="moveDualList( this.form.ctl00$MiddleContent$lbListLeft, this.form.ctl00$MiddleContent$lbListRight, true );"type="button"style="width:90"><BR></NOBR><NOBR><inputvalue="Add All <<"onclick="moveDualList( this.form.ctl00$MiddleContent$lbListRight, this.form.ctl00$MiddleContent$lbListLeft, true );"type="button"style="width:90"><BR></NOBR></td><td>

<br/>

<br/><asp:ListBoxRows="20"SelectionMode="Multiple"ID="lbListRight"runat="server"><asp:ListItem> RSL Club, 154 Railway Pde, Kogarah</asp:ListItem><asp:ListItem>2</asp:ListItem><asp:ListItem>3</asp:ListItem><asp:ListItem>4</asp:ListItem><asp:ListItem>5</asp:ListItem><asp:ListItem>D</asp:ListItem><asp:ListItem>G</asp:ListItem><asp:ListItem>K</asp:ListItem><asp:ListItem>Z</asp:ListItem><asp:ListItem>55</asp:ListItem></asp:ListBox></td>

</

tr>

<

tr><tdcolspan=3align=center><asp:ButtonID="btnSave"Text="Save"runat=server/></td></tr>

<

tr><tdcolspan=3>

</

td></tr>

</

table>

<

br/><br/><hr/><p><asp:PanelID="CollapseHeader"runat="server"style="cursor: pointer;"width="100%"><asp:LabelID="Label1"runat="server"Text="Label">Show Details...</asp:Label></asp:Panel><asp:PanelID="Panel2"runat="server"style="overflow:hidden;height:0"width="100%">

Not many details here. This is just a demo to show how the DropShadow will react properly to changes in the size of the panel it is attached to.

</asp:Panel><atlasToolkit:CollapsiblePanelExtenderID="cpe1"runat="server"><atlasToolkit:CollapsiblePanelPropertiesTargetControlID="Panel2"Collapsed="true"CollapsedText="Show Details..."ExpandedText="Hide Details"TextLabelID="Label1"ExpandControlID="CollapseHeader"CollapseControlID="CollapseHeader"SuppressPostBack="true"/></atlasToolkit:CollapsiblePanelExtender></p></div></asp:Panel><divclass="demobottom"></div></div><atlasToolkit:DropShadowExtenderID="dse"runat="server"><atlasToolkit:DropShadowPropertiesTargetControlID="Panel1"Width="5"Rounded='true'Opacity=".75"TrackPosition="true"ID="dsBehavior"/></atlasToolkit:DropShadowExtender>

<

SCRIPTLANGUAGE="JavaScript">

<!-- Begin

// Compare two options within a list by VALUES

function

compareOptionValues(a, b)

{

// Radix 10: for numeric values, Radix 36: for alphanumeric valuesvar sA = parseInt( a.value, 36 );var sB = parseInt( b.value, 36 );return sA - sB;

}

// Compare two options within a list by TEXT

function

compareOptionText(a, b)

{

// Radix 10: for numeric values, Radix 36: for alphanumeric valuesvar sA = parseInt( a.text, 36 );var sB = parseInt( b.text, 36 );return sA - sB;

}

// Dual list move function

function

moveDualList( srcList, destList, moveAll )

{

// Do nothing if nothing is selectedif (( srcList.selectedIndex == -1 ) && ( moveAll ==false ))

{

return;

}

newDestList =

new Array( destList.options.length );var len = 0;for( len = 0; len < destList.options.length; len++ )

{

if ( destList.options[ len ] !=null )

{

newDestList[ len ] =

new Option( destList.options[ len ].text, destList.options[ len ].value, destList.options[ len ].defaultSelected, destList.options[ len ].selected );

}

}

for(var i = 0; i < srcList.options.length; i++ )

{

if ( srcList.options[i] !=null && ( srcList.options[i].selected ==true || moveAll ) )

{

// Statements to perform if option is selected, Incorporate into new list

newDestList[ len ] =

new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );

len++;

}

}

// Sort out the new destination list

newDestList.sort( compareOptionValues );

// BY VALUES//newDestList.sort( compareOptionText ); // BY TEXT// Populate the destination with the items from the new arrayfor (var j = 0; j < newDestList.length; j++ )

{

if ( newDestList[ j ] !=null ) destList.options[ j ] = newDestList[ j ];

}

// Erase source list selected elementsfor(var i = srcList.options.length - 1; i >= 0; i-- )

{

if ( srcList.options[i] !=null && ( srcList.options[i].selected ==true || moveAll ) )

{

// Erase Source//srcList.options[i].value = ""; srcList.options[i].text = "";

srcList.options[i] =

null;

}

}

}

// End -->

</

script>

</asp:Content>

DropDownList, UpdatePanel, ControlEventTrigger and TimerControl affecting other UpdatePane

I've run across a problem so I've created some sample code below that replicates what I'm seeing.

I've got an UpdatePanel(up_Test) that has a control in it. I've got a TimerControl that fires every 2 seconds and my UpdatePanel has a Trigger to refresh on my TimerControl's Tick event.

I've got a DropDownList on the page(ddl_Test), with an AutoPostBack="true", I've got another UpdatePanel on the page that has a Trigger to refresh on my DropDownList's SelectedIndexChanged event. In this UpdatePanel I've got another DropDownList that gets its SelectedIndex set to the SelectedIndex of the first DropDownList.

Everything works as expected, except when I test it with IE6, when the TimerControl fires, the DropDownList in the second UpdatePanel gets refreshed. It doesn't seem to happen(or at least isn't noticable) with IE7(which is on the machine I'd been writing this on).

Basically, I wrote this big page that has a ton of different updatepanel's on it each with triggers to specific controls and that whole section worked great, but then on my masterpage, when I put a gridview with a timercontrol, suddenly, the page practically became unusable as all of the updatepanels suddenly trigger when the TimerControl fires. Is there some work-around I can do, or do I just need to drop the TimerControl and scrap the whole layout?

<

atlas:TimerControlID="tc_Test"runat="server"Interval="2000"Enabled="true"OnTick="tc_Test_Tick"/><atlas:UpdatePanelID="up_Test"runat="server"><ContentTemplate><asp:DropDownListID="ddl_Test"runat="server"></asp:DropDownList></ContentTemplate><Triggers><atlas:ControlEventTriggerControlID="tc_Test"EventName="Tick"/></Triggers></atlas:UpdatePanel><asp:DropDownListID="ddl_Test1"runat="server"AutoPostBack="true"OnSelectedIndexChanged="ddl_Test1_SelectedIndexChanged"/><atlas:UpdatePanelID="up_Test2"runat="server"><ContentTemplate><asp:DropDownListID="ddl_Test2"runat="server"></asp:DropDownList></ContentTemplate><Triggers><atlas:ControlEventTriggerControlID="ddl_Test1"EventName="SelectedIndexChanged"/></Triggers></atlas:UpdatePanel>

protected

void Page_Load(object sender,EventArgs e)

{

if (!Page.IsPostBack)

{

for (int i = 0; i < 10; i++)

{

string itemtext ="This is a long string to make it noticable " + i.ToString();

ddl_Test.Items.Add(itemtext);

ddl_Test1.Items.Add(itemtext);

ddl_Test2.Items.Add(itemtext);

}

}

}

protectedvoid ddl_Test1_SelectedIndexChanged(object sender,EventArgs e)

{

ddl_Test2.SelectedIndex = ddl_Test1.SelectedIndex;

}

protectedvoid tc_Test_Tick(object sender,EventArgs e)

{

Random r=newRandom();

ddl_Test.SelectedIndex = r.Next(9);

}

Mode="Conditional" on the update panels fixes the problem. I guess I just assumed putting in the <trigger> lines caused it to use the triggers but you have to change the updatepanel's mode too.

Wednesday, March 21, 2012

DropDownList event handler serevr side not called

Hello,

this is driving me crazy, below code does a post back to the server but DropDownList1_SelectedIndexChanged1 is never called on the server !
All other buttons work just fine !
If I remove the drop down list from the trigger, than it is called. What is going on here ?

<asp:dropdownlist id="DropDownList1" runat="server" autopostback="True" onselectedindexchanged="DropDownList1_SelectedIndexChanged1"
width="170px"></asp:dropdownlist>
<asp:updatepanel runat="server" id="upAvailability" updatemode="Conditional">
<ContentTemplate>
<asp:Label id="lbSearchResults" runat="server"/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btSearch"></asp:AsyncPostBackTrigger>
<asp:AsyncPostBackTrigger ControlID="btNavigateHotels"></asp:AsyncPostBackTrigger>
<asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged"></asp:AsyncPostBackTrigger>
</Triggers>
</asp:updatepanel>

Hi

I recreated your page and linked up some events and it works fine. Here is what I ended up with, if you want to compare to yours.

HTML

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged1" Width="170px">
<asp:ListItem Value="1" Text="option 1"></asp:ListItem>
<asp:ListItem Value="2" Text="option 2"></asp:ListItem>
<asp:ListItem Value="3" Text="option 3"></asp:ListItem>
</asp:DropDownList>
<asp:UpdatePanel runat="server" ID="upAvailability" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lbSearchResults" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btSearch" EventName="Click"></asp:AsyncPostBackTrigger>
<asp:AsyncPostBackTrigger ControlID="btNavigateHotels" EventName="Click"></asp:AsyncPostBackTrigger>
<asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged">
</asp:AsyncPostBackTrigger>
</Triggers>
</asp:UpdatePanel>
<asp:Button runat="server" ID="btSearch" Text="search" OnClick="btSearch_Click" />
<asp:Button runat="server" ID="btNavigateHotels" Text="navigate hotels" OnClick="btNavigateHotels_Click" />
</form>

Codebehind

protected void Page_Load(object sender, EventArgs e)
{

}
protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
{
lbSearchResults.Text = DropDownList1.SelectedItem.Text;
}
protected void btSearch_Click(object sender, EventArgs e)
{
lbSearchResults.Text = "Search";
}
protected void btNavigateHotels_Click(object sender, EventArgs e)
{
lbSearchResults.Text = "Navigate Hotels";
}

All the events fire correctly. When I attached to the aspnet_wp I could step through the events, and the label control reflected the text I wrote into it.

I even tried calling DataBind() on the DropDownList to see if that killed the event, but it still worked.

I bet thats even more frustrating? :)

Could you post more of your code/page so i can replicate exactly what you have?

Thanks

PaulTAG


Paul.

thanks for your great help on this. I worked around the problem by calling the event handler myself via checking the __EVENTTARGET of the form.

It is very weird because if I add another drop down list this one gets called ! Looking into the Forms collection on the server I cant find the method names there, also not for the buttons which do work (meaning I do not find any Button1_Click in any form value). How does this work, how does ASP know what method to call on the server ? I could than see why this is not happening in my case

Thanks

Joe

Dropdownlist doesnt refresh in Updatepanel

Hi all,

I'm just taking my first steps in the altlas world here, so i guess the problem below will be due to myself:

i created an .aspx page containing some dropdowns, and coded the functionality using postbacks. Up until there it all works. Then i tried to refresh one of the dropdowns using Atlas - triggered by another dropdown control.

Now when i change the selected value in the "trigger" control, the code filling the other dropdown is executed but the controls content isn't refreshed when the execution is completed.

Here's the code on the aspx page...

...

<atlas:ScriptManager ID="s" EnablePartialRendering="true" runat="server"></atlas:ScriptManager>

...

SalesCompany:<asp:DropDownList ID="ddlSalesCompany" runat="server" OnSelectedIndexChanged="ddlSalesCompany_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList><br/>
Series:<asp:DropDownList ID="ddlSeries" runat="server" OnSelectedIndexChanged="ddlSeries_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList><br/>
<atlas:UpdatePanel ID="up1" runat="server">
<ContentTemplate>
Model:<asp:DropDownList ID="ddlModel" runat="server" OnSelectedIndexChanged="ddlModel_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList><br/>
</ContentTemplate>
<Triggers>
<atlas:ControlValueTrigger ControlID="ddlSeries" PropertyName="SelectedIndex" />
</Triggers>
</atlas:UpdatePanel>

in my "code behind" page i have:

protected void ddlSeries_SelectedIndexChanged(object sender, EventArgs e)
{
FillModels();
}

private void FillModels()
{
if (ddlSeries.SelectedValue != "0")
{
Proxy.Pricing.Model.ModelService ModelSVC = new Proxy.Pricing.Model.ModelService();
DKSerie dkSerie = new DKSerie(ddlSeries.SelectedValue.ToString());

List<Model> myModels = ModelSVC.GetModels(dkSerie, null);

ddlModel.DataSource = myModels;
ddlModel.DataTextField = "Name";
ddlModel.DataValueField = "OID";
ddlModel.DataBind();

ddlModel.Items.Insert(0, new ListItem("Select a model", "0"));
}
else
{
ddlModel.Items.Clear();
ddlModel.Items.Insert(0, new ListItem("Select a series", "0"));
}
}

Can somebody help me on this one?

Thanks in advance,

Wesley Van den Eede

The thing that triggers the UpdatePanel is the Triggers Collection of the Update Panel. I noticed in your Triggers Collection you have the property of the trigger to be "SelectedIndex" where it probably should be "SelectedIndexChanged" (at least it is in mine).

Mike


Hi Mike,

Thanks for the reply, but...

Isn't that in case i use a ControlEventTrigger instead of a ControlValueTrigger?

I watched Scott's presentation athttp://atlas.asp.net/ and he uses SelectedIndex.

Wesley


Sorry for the double post...

The thing is that, i don't think it is related to the trigger... because when i debug and put a breakpoint on the FillModels() function, the debugger really steps in. It looks like the actual rendering of the control isn't refreshed?

Wesley


Can you monitor the network traffic using Fiddler or Nikhil's browser helper and tell us what you see?

Hi,

Sorry for the late reply (working on another project :))

Today i tried to use fiddler a bit, but then i found out that it doesn't work with IE7?, I'll try to send the fiddler output this afternoon anyway.

On the other hand i did some more investigation and found out that it is probably related to two other controls i use further in the page: Infragistics.WebUI.WebDateChooser.v1.2

When i remove the controls it all works, so i guess it's now a case of making them work together (or replacing the WebDateChooser controls) ... any suggestions?

Kind regards,

Wesley Van den Eede


Yes, we know of a few problems with the Infragistics controls which are quite heavily using JavaScript.

I just updated our datepicker controls to the latest trial version of the netadvantage suite (2006 Vol. 1) ... now it works perfectly...

Thanks for the responses.

DropDownExtender in a GridView issues (v1.0 beta)

I am trying to add a DropDownExtender within a GridView control using the code below but it fails i.e. The DropDownExtender is never displayed (no javascript errors). Then if I use the paging in the gridview to navigate to another page and hover over a row it causes a javascript error 'Line 196 Error: Object doesn't support this method or property'.

I've tried this with other controls (e.g. TextboxWatermark) in a GridView and they work ok but are a bit glitchy. Is this a known issue?

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataKeyNames="Number,Sequence" DataSourceID="SqlDataSource1">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Panel ID="DropPanel" runat="server" CssClass="ContextMenuPanel" Style='display:none;visibility:hidden;'>
<asp:LinkButton runat="server" ID="Option1" Text="Option 1" CssClass="ContextMenuItem" OnClick="OnSelect" />
<asp:LinkButton runat="server" ID="Option2" Text="Option 2" CssClass="ContextMenuItem" OnClick="OnSelect" />
<asp:LinkButton runat="server" ID="Option3" Text="Option 3 (Click Me!)" CssClass="ContextMenuItem" OnClick="OnSelect" />
</asp:Panel>
<asp:Label ID="TheLabel" runat="server" Text="Howydoing" />
<ajaxToolkit:DropDownExtender ID="DDE" runat="server" DropDownControlID="DropPanel" TargetControlID="TheLabel"/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Number" HeaderText="Number" ReadOnly="True" SortExpression="Number" />
<asp:BoundField DataField="Sequence" HeaderText="Sequence" ReadOnly="True" SortExpression="Sequence" />
<asp:BoundField DataField="Reference" HeaderText="Reference" SortExpression="Reference" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
</Columns>
</asp:GridView>

Javascript where error occurs is: (this is part of the AjaxControlToolkit runtime scripts):

// NOTE: [rb] replaced with CommonToolkitScripts version
// var offsetParentLocation = Sys.UI.DomElement.getLocation(offsetParent);
// var parentBounds = Sys.UI.DomElement.getBounds(parent);
var offsetParentLocation = CommonToolkitScripts.getLocation(offsetParent);
var parentBounds = CommonToolkitScripts.getBounds(parent);

The problem here looks to be an issue with the current beta of ASP.NET AJAX, and I am following up with Shawn Burke and the ASP.NET AJAX team at Microsoft. The issue at hand is that ScriptManager currently emits all of its script for Extenders and ScriptReferences in it's own PreRender event which will happen before the PreRender event of the GridView. In the initial page request (Page.IsPostBack == false), a GridView bound using DataSourceID will delay binding until the last possible moment, which happens to be PreRender.

Until the ASP.NET AJAX team can address this issue, the quickest way to solve the bug is to temporarily add the following code to your Page or UserControl:

1protected void Page_Load(object sender, EventArgs e)2{3if (!Page.IsPostBack)4 {5 Grid.DataBind();6 }7}8 

Where Grid is the name of your DataGrid. This will cause the binding to the DataSourceID to happen in Load as opposed to PreRender.

Try the above and see if it solves your problem. I have another application I am working on that is exhibiting the same issue and this fixed it.


Thanks for that - that solved part of the problem to do with why it wasn't working on the first page display, however I was still getting the Javascript error. After a bit of debugging I found the following error in AjaxControlToolkit\Common\Common.js Line 196, which read:

var mediumThickness = this.parseBorderThickness("medium");

parseBorderThickness doesn't exist. however _borderThicknesses does and has values for thin, medium and thick. So changing the line to read:

var mediumThickness = this._borderThicknesses.medium;

solved the issue, however the DropDown is not quite aligned properly with the text so it looks like there is some additional work required in this area - maybe this will be fixed in the next release.


Thanks for pointing that out, that was a bad reference. The correct function name isparseBorderWidth not parseBorderThickness. I have made the change and checked it in and it should be corrected in the next toolkit release.

Can you provide me with some further details as to the alignment issue, or a sample I might be able to look at (source code/designwise) that I can try to use to figure out what might be causing a problem with the offset?


Source code is below. There are 2 issues:

1) The alignment of the DropDown box when hovering over 'TheLabel' is wrong in IE 6. This is correct when using Firefox 2.0. I am able to resolve this in IE by modifying the Common.js file like so:

if(defaultTdLeftBorderFound) offsetX -= mediumThickness + 4; //(Previously was -1)
if(defaultTdTopBorderFound) offsetY -= mediumThickness + 3; //(Previously was -1)

2) The glitchy behaviour I mentioned earlier seems to be a problem with other controls as well (at least TextBoxWatermark) which occurs when you navigate to the last page in a paged grid. I get a Javascript error in MicrosoftAjax.js: Line 451: Error: '_behaviors' is null or not an object

Default.aspx:
<%@. Page Language="C#" AutoEventWireup="true" %>
<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<script runat="server">
protected void Page_Load(Object sender, EventArgs args)
{
if (!Page.IsPostBack)
{
GridView1.DataBind();
}
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style>
.ContextMenuPanel
{
background-color:white;
border: 1px solid #868686;
z-index: 1000;
cursor: default;
padding: 1px 1px 0px 1px;
font-size: 11px;
}
a.ContextMenuItem
{
display: block;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataKeyNames="Number,Sequence" DataSourceID="XmlDataSource2">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Panel ID="DropPanel" runat="server" CssClass="ContextMenuPanel" Style='display:none;visibility:hidden;'>
<asp:LinkButton runat="server" ID="Option1" Text="Option 1" CssClass="ContextMenuItem" />
<asp:LinkButton runat="server" ID="Option2" Text="Option 2" CssClass="ContextMenuItem" />
<asp:LinkButton runat="server" ID="Option3" Text="Option 3 (Click Me!)" CssClass="ContextMenuItem" />
</asp:Panel>
<asp:Label ID="TheLabel" runat="server" Text="Howydoing" />
<ajaxToolkit:DropDownExtender ID="DDE" runat="server" DropDownControlID="DropPanel" TargetControlID="TheLabel"/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Number" HeaderText="Number" ReadOnly="True" SortExpression="Number" />
<asp:BoundField DataField="Sequence" HeaderText="Sequence" ReadOnly="True" SortExpression="Sequence" />
<asp:BoundField DataField="Reference" HeaderText="Reference" SortExpression="Reference" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
</Columns>
</asp:GridView>
<asp:XmlDataSource ID="XmlDataSource2" runat="server">
<Data>
<TheData>
<row Number="asdfasdf" Sequence="001" Title="eflwef fwe " Reference="fwefwewefwef"/>
<row Number="asdfasdf" Sequence="002" Title="eflwef fwe " Reference="fwefwewefwef"/>
<row Number="asdfasdf" Sequence="003" Title="eflwef fwe " Reference="fwefwewefwef"/>
<row Number="asdfasdf" Sequence="004" Title="eflwef fwe " Reference="fwefwewefwef"/>
<row Number="asdfasdf" Sequence="005" Title="eflwef fwe " Reference="fwefwewefwef"/>
<row Number="asdfasdf" Sequence="006" Title="eflwef fwe " Reference="fwefwewefwef"/>
<row Number="asdfasdf" Sequence="007" Title="eflwef fwe " Reference="fwefwewefwef"/>
<row Number="asdfasdf" Sequence="008" Title="eflwef fwe " Reference="fwefwewefwef"/>
<row Number="asdfasdf" Sequence="009" Title="eflwef fwe " Reference="fwefwewefwef"/>
<row Number="asdfasdf" Sequence="010" Title="eflwef fwe " Reference="fwefwewefwef"/>
<row Number="asdfasdf" Sequence="011" Title="eflwef fwe " Reference="fwefwewefwef"/>
<row Number="asdfasdf" Sequence="012" Title="eflwef fwe " Reference="fwefwewefwef"/>
<row Number="asdfasdf" Sequence="013" Title="eflwef fwe " Reference="fwefwewefwef"/>
</TheData>
</Data>
</asp:XmlDataSource>
</div>
</form>
</body>
</html>

Notes: Web.config is taken direct from C:\Program Files\MicrosoftASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025\web_CTP.config and needsreferences to Microsoft.Web.Preview.dll and AjaxControlToolkit.dll


I've found that using a repeater table works just fine, but I continue to have problems with the GridView.

Suman Chakrabarti [MSFT]


I notive the alignment problem when placed inside a table with a border > 0px . If I set the boder to zero it lines up.
is this fixed in the current downloadable rc1 version?

Hi,

did you solve this problem? I have got the same problem at the moment. Is there a solution available?

--edit--

I just saw, my code is a little bit different

 <asp:HyperLink ID="hl1" runat="Server" NavigateUrl='<%# Eval("Id")%>' OnDataBinding="hl1_DataBinding"><asp:Label ID="TheLabel" runat="server" Text="Howydoing" /></asp:HyperLink>