Showing posts with label items. Show all posts
Showing posts with label items. Show all posts

Monday, March 26, 2012

Duplicate Items in dropdownlist inside an Updatepanel

Hi,

I have been working with Atlas for the past couple of weeks and I have a very simple page with a dropdownlist box inside a updatepanel. I have a button that inserts a value in the back-end database and refresh the dropdownlist. This button is also a trigger for the updatepanel. This dropdownlist is bounded to an ObjectDataSource.

The problem is that on the first click, the values in the dropdownlist are duplicated with the original list and plus the new value. So I have the original list show up twice and the new value at the end. However, on the second click, the dropdownlist is updated correctly with only the new value being appended at the end. Doesn't anyone have the same problem?

ThanksSmile

<atlas:UpdatePanelID="UpdatePanelReason"runat="server"Mode="Conditional">

<ContentTemplate>

<asp:DropDownListID="drpReason"runat="server"AppendDataBoundItems="True"DataSourceID="ObjectDataSource1"DataTextField="ITEM_SUB_TYPE_NAME"DataValueField="PK_ITEM_SUB_TYPE_ID">

<asp:ListItemValue="0">Select Reason</asp:ListItem>

</asp:DropDownList>

</ContentTemplate>

<Triggers>

<atlas:ControlEventTriggerControlID="btnAddReason"EventName="Click"/>

</Triggers>

</atlas:UpdatePanel>

My post-back method to insert a new value in the dropdownlist.

ProtectedSub btnAddReason_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles btnAddReason.Click

IfMe.txtNewReason.Text <>String.EmptyThen

Dim lookupMgrAsNew LookupManager

lookupMgr.insertItemSubType(Me.txtNewReason.Text, Session("ItemType"))

Me.drpReason.DataBind()

EndIf

EndSub

Problem solved!! All I have to do is clear all the items in the dropdownlist before calling databinding.

:)

DropShadowExtender and asp .net 2.0 Menu Control

Hi, i'm having a problem using DropShadowExtender, when i use it in a panel bellow my menu (menu displaying items in hotizontal with children), the children menu items, appear behind the panel witch the DropShadowExtender is bounded.

Has anyone expererienced this? If so is there a simple solution to it?

I've tried to change several properties of the div where my menu is inserted, and did'nt work.

Thanks.

hi joao_matos,

Could you provide some sample code that shows what's going wrong? I'm not quite following your description.

Thanks,
Ted

Saturday, March 24, 2012

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>

DropShadow hides my menu items on back

I used dropshadow and when I pull down menut item to navigate to other page I cannot click on it as it's hide behind dropshadowextender?

On the menu element, try setting:

<asp:Menu id="Menu1" style="position:relative:z-index:5" ... >


I tried this and this does not work! The shadow override the menus.

This worked when I removed this tag:

<

atlasToolkit:DropShadowExtenderID="dse"runat="server"><atlasToolkit:DropShadowPropertiesTargetControlID="Panel1"Width="5"Rounded='true'Opacity=".75"TrackPosition="true"ID="dsBehavior"/>

</

atlasToolkit:DropShadowExtender>

Yes I had to remove the shadow to get this going even though my menu has:

<asp:MenuID="Menu1"runat="server"DataSourceID="SiteMapDataSource1"Font-Bold="true"style="position:relative; z-index:5">

It's the 2nd level menus that are hidden underneath the shadow. I think it completely ignores the Z-index of the menu


That worked for me but I have more question,

1) how to make size of both panel and table look same so that I have good effect of drop shadow, as with the below code my panel is too big and table is inside the panel. I tried to make size of both table and panel same still does not work.

2)How to use different color besides black for shadow?

<

asp:PanelID="pnlTable"runat="server">
<tableclass="table">
<tr>
|<tdcolspan="2"class="heading">Search Parts By Supplier or Return Parts</td>
</tr>
<tr>
<tdclass="tdheading">Supplier ID</td>
<td><asp:TextBoxID="txtsearchsuppID"runat="server"Width="208px"></asp:TextBox></td>
</tr>
<tr>
<tdclass="tdheading">From Date<asp:TextBoxID="txtfromdate"runat="server"></asp:TextBox>
<asp:PanelID="pnlFrom"runat="server">
<asp:CalendarID="fromClnd"runat="server"OnSelectionChanged="fromClnd_SelectionChanged">
</asp:Calendar>
</asp:Panel><cc1:CollapsiblePanelExtenderID="CPEfromClnd"runat="server"><cc1:CollapsiblePanelPropertiesCollapseControlID="txtfromdate"Collapsed="True"AutoCollapse="True"AutoExpand="True"CollapsedSize="0"ExpandControlID="txtfromdate"ExpandedSize="180"TargetControlID="pnlFrom"/></cc1:CollapsiblePanelExtender></td></tr>
<tr>
<tdcolspan="2"><asp:ButtonID="btnSearch"runat="server"Text="Search"OnClick="btnSearch_Click"/>
</td></tr>
</table></asp:Panel>

The DropShadow isn't ignoring the zIndex of the menu - it has no knowledge of it. I suspect that the sub-menu items created by the ASP.NET menu control don't have zIndexes on them, so they default to 0 which causes them to show up beneath the dropshadow items.


The Sub Menus don't have a style property to adjust unlike the asp:Menu. They have a CssClass which is what I'm assuming you mean.

I removed the following off the panel to show the underlying shadow.

CssClass="dropShadowPanel"

Then I placed z-index: 155 everywhere for the menu.

<asp:MenuID="Menu1"runat="server"DataSourceID="SiteMapDataSource1"StaticDisplayLevels="1"Font-Bold="true"Style="z-index:115"><StaticMenuItemStyleCssClass="MenuStyle"VerticalPadding="2px"/><DynamicHoverStyleCssClass="MenuStyle"BackColor="#e1ecfc"/><DynamicMenuItemStyleCssClass="MenuStyle"BackColor="#e1ecfc"/></asp:Menu>

.MenuStyle

{FONT-SIZE:8pt;VERTICAL-ALIGN:top;FONT-FAMILY:verdana;PADDING-BOTTOM:5px;z-index:115}

The menu appears beneath the shadow regardless of all the combinations I have tried.

A quick fix but I lose screen space is:

StaticDisplayLevels

="2"


Oh - ok. Yeah, the dropshadow is absolutely positioned. Since your items are statically positioned, they have a different zIndex stack. Sorry, I didn't think of that. Try adding "position:relative" to your MenuStyle class (and specify that on your Menu control's CssClass property too).


No you're not slipping. You mentioned that before. :)

It's beyond me. I've gone throught the 2 stylesheets I have and I can't figure it out.

I'm down to:

<asp:MenuID="Menu1"runat="server"DataSourceID="SiteMapDataSource1"StaticDisplayLevels="1"Font-Bold="true"Style="position:relative; z-index:30"><StaticMenuItemStyleCssClass="MenuStyle"VerticalPadding="2px"/><DynamicHoverStyleCssClass="MenuStyle"BackColor="#e1ecfc"/><DynamicMenuItemStyleCssClass="MenuStyle"BackColor="#e1ecfc"/></asp:Menu>

.MenuStyle

{FONT-SIZE:8pt;VERTICAL-ALIGN:top;FONT-FAMILY:verdana;PADDING-BOTTOM:5px;position:relative;z-index:30}

On load up it flashes ontop then quickly reverts underneath. I'musing IE6.0 SP2. I'll send the source if you are really keen! :)


I have same issue like Glyder, on load up it flashes for a second for many Atlast control like dropshadow, collapsible Panel etc.
second issue is I loose my css style sheet setting any where I use atlas control. when it post back it settings are applied.
Example:

Suppose I applied css="table" for table it does not take affect until first post back, how to take care of this both problem.This will be really helpful if we can figure this out.


Hmm - yeah I'd like to take a look at this. If you could send me a repro, I'd appreciate it.
what is repro? my code?
<atlas:ScriptManagerID="SM"EnablePartialRendering="true"runat="server"></atlas:ScriptManager><atlas:UpdateProgressID="Progress"runat="server"><ProgressTemplate>

Updating Please Wait...

<imgalt="Wait"id="ImgWait"src="Images/Wait_indicator_flower.gif"/></ProgressTemplate></atlas:UpdateProgress>
<atlas:UpdatePanelID="Up1"runat="server"><ContentTemplate><asp:PanelID="pnlParent"DefaultButton="btnaddparSupp"runat="server"Visible="False"><tableclass="table"><tr><tdcolspan="2"class="heading1">

Supplier Maintenance - Setting up New Supplier Information

</td></tr><tr><tdstyle="width: 153px"align="left">

Supplier Name

</td><tdstyle="width: 334px"align="left"><asp:TextBoxID="txtparSuppName"runat="server"></asp:TextBox><asp:RequiredFieldValidatorID="ReqParSuppName"runat="server"ControlToValidate="txtparsuppName"ErrorMessage="Req"></asp:RequiredFieldValidator></td></tr>

<

tr><tdalign="center"colspan="2"class="tdheading"><asp:ButtonID="btnaddparSupp"runat="server"Text="Add"/><asp:ButtonID="btncancelparSupp"runat="server"CausesValidation="False"EnableViewState="False"Text="Cancel"/></td></tr></table></asp:Panel></ContentTemplate><Triggers><atlas:ControlEventTriggerControlID="btnParent"EventName="Click"/></Triggers></atlas:UpdatePanel>

The XHTML you're using including the menu, the DropShadowExtender, and the panel it's targeting please.

Also, please use a smaller font size when pasting in code. Thanks.


Hi, I've the same problem as you, and I found a workaround:
I have a panel where my menu is:
<asp:Panel ID="menuPanel" runat="server" CssClass="menuDiv" Style="z-index:115">
<asp:Menu ID="Menu1" runat="server">
<Items>
... (items)
</Items>
<StaticHoverStyle BackColor="#990000" ForeColor="White" />
</asp:Menu>
</asp:Panel>
then other panel for the content of the page:
<asp:Panel ID="mainPanel" runat="server" CssClass="mainDiv">
...
</asp:Panel>
then I apply the shadow to the mainPanel, but also I have to apply shadows to menuPanel (otherwise doesn't work):
<cc1:DropShadowExtender ID="DropShadowExtender1" runat="server">
<cc1:DropShadowProperties TargetControlID="mainPanel" />
</cc1:DropShadowExtender
<cc1:DropShadowExtender ID="DropShadowExtender2" runat="server">
<cc1:DropShadowProperties TargetControlID="menuPanel" />
</cc1:DropShadowExtender>
And it works!!! but that's not the perfect way. As you can see I have to apply shadow on both panels, and in the menuPanel I have to put  Style="z-index:115", and the most strange is that if a put z-index in a CssClass (menuDiv in my case) i doesn't work, I have to put it in the control itself.

Haha, thanks Matias I was able to get around a similar issue by using your method.

Dropdownlist with non-selectable items

Hi all,

I've been using AJAX and the Toolkit. I don't know much about authoring my own controls, so I'll need a lot of help here. Basically what I want is a dropdownlist where some of the items in the list are non-selectable. I can then use the non-selectable items to group selectable items together. For example:

Imagine the following items in a Dropdownlist:

-- Fruit --

Apple

Orange

Banana

-- Vegetables --

Carrot

Onion

Garlic

I want the items "Fruit" and "Vegetables" should be non-selectable. I could always do this with two cascading dropdown lists but this is a more user-friendly solution (less controls, less clicks, etc). It was also requested by my clients.

You can check ,

DropDownList.SelectedIndex property for perticauler position value.

If it is --Fruit-- or --Vegetables-- try to re-set index of dropdownlist.


I suggested that to the clients butthey want these items to be static - i.e. don't even give the user the chance to select them.

In other words, when you hover your mouse over --Fruit-- or --Vegetable-- ListItems, theyshouldn'tbe highlighted or selectable at all. If the user tries to click on one of them, the DropDownList should just continue to be expanded as if nothing happened.

DropDownList SelectedIndexChanged not firing

I have an issue with a DDL where my SelectedIndexChanged only gets fired when the second list item is selected (there are only 2 items in the list). The first item in the list is the default item and is set to selected. Also the list items are not bound via a datasource, they are already populated.

The DDL is wired up to the UpdatePanel as a Trigger. The DDL is also located outside the UpdatePanel - I tried having the DDL inside the UpdatePanel as well but the same issue comes up.

The Update does occur because I verified that the Page_Load fires when I switch between the two DDL items.

Any ideas?

The trick to this is to insert another record as the default selection of the DDL. I always insert a ListItem at run-time right after I bind the records to the DDL that tells the user to make a selection, for example 'Select State'. This solves two problems, it helps guide the user (let's face they need all the help they can get) and will force the selectedindexchanged event to fire like you want.

ddlState.Items.Insert(0,New ListItem("Select a State", 0))

Here is a Blog entry I made on the topic:

http://professionalaspnet.com/archive/2007/12/22/Cures-for-the-Common-Ailments-_2D00_-DropDownList.aspx


I was hoping that wasn't the fix but I guess I'll just have to work with it.

Thanks!


Have you set the property named "ChildrenAsTriggers" of the UpdatePanel to true?

DropDownList SelectedIndexChanged event not firing

I have a dropdown list that has many items in it - so in order to reduce viewstate size I have shut off viewstate for that control. But since doing so - the selectedindexchanged event is not firing (I guess because without view state the control does not know if there was a change in the selected value so it can't determine if it should fire the changed event.

Is there any way I can detect this change on the client and fire the selectedindexchanged event on the server?

thanks
Michael

May be you can try to bind the dropdown list in the Page_Init event handler.. Then you do not have to worry about viewstate.. Give it a try..


I tried that but that means everytime there is a postback (async or sync) it has to hit the db to re-populate that list.

I tried keeping track of the previously selected value in viewstate manually to detect a change and it detected the change correctly but I get an event validation error.

thanks
Michael


ok. I guess we are missing the pieces of information here... So you do not care about re-populating the list again? so what is going to be in the list.. after the postback is finished?

What event validation error you are talking about? Do you even care about the SelectIndexChanged event? Or you can simply explain more about what exactly you are trying to do?


I have a drop down list with autopostback = true and when an item is selected an update panel will refresh based on the selected item in the dropdown list. So I don't need to reload the dropdown list once it is loaded initially.

I actually solved the issue by looking at the event source in the forms collection and if it is the dropdown list - I know that the selected item was changed because the dropdown list won't do a postback unless the selected item was changed. I couldn't use the selecteditemchanged event because with the viewstate disabled - the server side does not know if the selected item changed.

I thought I had to store the previously selected item in viewstate to detect if a new item was selected but it turns out that a postback only occurs when the selected item is changed - which makes sense - the browser know that the item was changed - even though the server does not.

thanks
Michael

dropdownlist inside a update panel is not updating

Hello,
I have a update panel and inside that panel I have three items, dropdownlist, text box and button.
Dropdownlist is being bound to select statement (SqlDatasource) which retrieve list of boxes borrow by department.
Text box is used to updated the information for person name who returned the box.
Button is used when I want to update the information for a retunbox.in the button event handler I update the status of box from borrow to return with the name of the return person and display the information result to end user for success of failure.

I can see the sauces information on the gui and also see the in the database it is updating.
When I refresh the page it remove that box number from the dropdownlist but not when I click the button to update the information. I have set the trigger for updatepanel to conditional mode with button click.

I also try to programatically updated the dropdownlist (both when first time it load the page and on clicking the button) but it still didn't work.

Any help would be really appreciated.

Thanks

F5 refresh doesnot support in Ajax and there is no need for the trigger as the button is already inside the update panel since all child controls are trigger by default

rohit


Thanks.

But the problem still remains same, dropdownlist is not updated once the button is clicked and it has changed the status from borrowed to retuned in the database. Dropdownlist still show the box number as borrowed box.


I assume your button click calls a function.

In that case try to call the update function of the updatepanel.

e.g. <asp:UpdatePanel ID="MyUpdatePanel" .........

Button Click Function:

MyUpdatePanel.Update();

If it's not working, post your HTML here so others can help.

Aeires.


No, this doesn't work.

Here is the code:

<asp:UpdatePanel ID="updatePanelBorrow" runat="server">
<contenttemplate>

<asp:Panel id = "plborrrow" runat="server">

<asp:DropDownList onblur="ResetColor()" id="ddlQABoxList" onfocus="ChangeColor()" tabIndex=3 runat="server" Width="154px" ToolTip="Select SafeGuard No to Borrow it" AppendDataBoundItems="True" CausesValidation="True"><asp:ListItem Value="-1">Choose a SafeGuard</asp:ListItem></asp:DropDownList>

<asp:Textbox id="txtname" runat="server"/>

<asp:Button id="btnSaveBorrow" tabIndex=8 onclick="btnSaveBorrow_Click" runat="server" Text="Save Borrow Info" Width="111px" SkinID="TopPanelSkinID" ToolTip="Update Borrow information for the Safeguard box or QA Box"></asp:Button

</asp:Panel>
</contenttemplate>

</asp:UpdatePanel>

Here is code : first to bind dropdownlist (it is basically box numbers)

public void GetQABoxList()
{
_connection = new SqlConnection(_connString);
//The command object for sql statement
_command = new SqlCommand();
try
{
_connection.Open();
_command.Connection = _connection;
_command.CommandText = "spListOfQABoxes";
_command.CommandType = CommandType.StoredProcedure;

//Execute the insert statemtent

dataAdapter = new SqlDataAdapter();
dataAdapter.SelectCommand = _command;
dataAdapter.TableMappings.Add("Table", "[QA Box]");

DataSet dataset = new DataSet();
dataAdapter.Fill(dataset);

ddlQABoxList.DataSource = dataset.Tables["[QA Box]"].DefaultView;
ddlQABoxList.DataTextField = "boxNo";
ddlQABoxList.DataValueField = "boxNo";
ddlQABoxList.DataBind();

}
catch (Exception exp)
{
Trace.Write(exp.Message);
}
finally
{
_command.Dispose();
_connection.Close();
}
}

Code for button click:

protected void btnSaveBorrow_Click(object sender, EventArgs e)
{
lblMessage.Visible = false;
lblMessage.Text = "";
String boxno = ddlQABoxList.SelectedItem.Text;


_connection = new SqlConnection(_connString);

//The command object for sql statement
_command = new SqlCommand();
try
{
_connection.Open();
_transaction = _connection.BeginTransaction();
_command.Transaction = _transaction;
_command.Connection = _connection;

_command.CommandType = CommandType.StoredProcedure;
_command.CommandText = "spUpdateBorrowBoxInfo";

//Execute the insert statemtent
int val = _command.ExecuteNonQuery();
if (val > 0)
{
plReturn.Visible = false;
lblMessage.Visible = true;
lblMessage.Text = "Borrow information for QA Box # " + boxno + " has been Updated";

// ddlQABoxList.DataSource = dsBorrowBox;
// ddlQABoxList.DataBind();

txtBorrowedName.Text = "";
txtContents.Text = "";
}
_transaction.Commit();
// GetQABoxList();
DataBindDept();
}
catch (Exception exp)
{
lblMessage.Visible = true;
lblMessage.Text = exp.Message.ToString();
Page.SetFocus(ddlQABoxList);
Trace.Write(exp.Message);
}
finally
{
_command.Dispose();
_connection.Close();
}
// GetQABoxList(); use these two lines to enforce to update dropdownlist, NO SUCCESS!
// UpdatePanelAndDDL();
}

it looks like your problem is the dropdown is not refreshing after button click event, for that u need to call GetQABoxList() againg to refresh your dropdown list.

if this is not what you want then please explain your problem more clearly.

Rohit


Well, In the button_Click eventhandler I do call the GetQABoxList() as my primary concern is to get the latest list of qa boxes numbers to bind with dropdownlist. I commnet out this method but it was not working for me.

Thanks


try putting

ddlQABoxList.SelectedIndex = 0 at the end of GetQABoxList() and see if it works for you.


and one thing include

ddlQABoxList.Clear() in the the begining and

ddlQABoxList.SelectedIndex = 0 at the ending

inside the GetQABoxList() subroutine

and make sure there should not be any javascript error shown on ststus bar

i hope it helps

Rohit


Thanks

It work fine with the suggestion you gave.

Wednesday, March 21, 2012

DropDownList Flicker, Rendering and Slow

I keep noticing a flicker on a dropdown with only three items in it. These three items don't change between postbacks, so why is the UpdatePannel rendering them again?

Also, there is a similar problem with listboxes:

UpdatePanel PartialRendering large ListBoxes
http://forums.asp.net/thread/1363249.aspx

and it looks like large listboxes and dropdowns are both taking a long time for the callback to complete. Any ideas?

Try setting the UpdatePanel's

Mode="Conditional"

to fix the UpdatePanel always rendering issue. As to flickering, not sure on that one. I haven't seen it personally, but it may be browser specific. Have you tried this in different browsers to see what the effect is?


Hi,

as Glav suggested, the DropDownList flickering is specific to IE6. It is an issue in how the browser renders boxed elements, and I think it has been fixed in IE7beta.
Regarding the rendering delay, it may be related to dynamic DOM manipulation (for a DropDownList inside an UpdatePanel, recall that it will be rendered and dynamically populated on every partial postback) thus this is not an Atlas-specific issue and also you may experience it on almost all browsers (but maybe IE will be slower than others).

Thanks Paul.

That works for a lot of things. The trouble is I have a robust, windows like UI with a lot of controls in a browser with various master-detail-detail-detail style panels, so:

  • In the simple case, having several conditional UpdatePanels handle several Controls each, the Triggers aren't too bad between UpdatePanels, but DropDownLists and ListBoxes within the same UpdatePanel still get re-rendered.

    Thanks Garbin, that's good to know

    I'm not manipulating the DropDownList at all. Even an empty list exhibits this behavior, but it does appear that Atlas is unnecessarily manipulating the DOM for DropDownLists and ListBoxes, so I would need to argue that this is anAtlas-specific issue.

    I think DropDownList and ListBoxes still need a lot of work and hopefully it will at least get looked at for the Atlas August CTP, because right now they are ridiculously slow.

    See my other post:

    UpdatePanel PartialRendering large ListBoxes
    http://forums.asp.net/thread/1363249.aspx

    From my vantage, it's a big enough of an issue where I wouldn't even consider deploying any sites done with Atlas until this improves. Maxing out the CPU on a client for any length time is just not acceptable.

    Best Regards,

    Dan


    Hi,

    dbDan:


    I'm not manipulating the DropDownList at all. Even an empty listexhibits this behavior, but it does appear that Atlas is unnecessarilymanipulating the DOM for DropDownLists and ListBoxes, so I would needto argue that this is anAtlas-specific issue.


    are you referring to the flickering issue or the slow rendering? The first one is IE-specific, while I can't think of the second one as an Atlas-specific issue, since dynamically adding 5000 items to a ListBox using pure JavaScript (no Atlas) is slowing down IE, FireFox, Opera (I didn't test it on other browsers).

    Hi Garbin,

    I'm sure you're right about the flickering, but I haven't had a chance to check out IE 7 yet.

    This post was intended to be more about "unnecessary" rendering which causes "slow" rendering to occur more often. I guess I'm looking for some way to tell the ScriptManager that certain triggers are to hide/unhide the entire panel or maybe even just one control only, so it could be a little smarter about things.

    In any case, it doesn't matter if you create a ListBox with static HTML, with JavaScript or as a Databound ListBox. It originally renders fine. But if it's in an UpdatePanel with PartialRendering enabled, the callback has some serious problems.

    This post is just part of the issue, what I consider the real problem is described better in my other post.

    http://forums.asp.net/thread/1363249.aspx

    It got a low priority. I should have called it the "Atlas Callback CPU Loop Hog" bug or something, to see if that would at least get a semi-low priority :)

    So that leaves me wondering if there is a way to get this issue/problem escalated to the point where someone will at least look at to see if its a simple fix or not.

    Thanks,

    Dan


    I have a little more info on this one. I did a release to a Windows 2003 staging server. Although the delay is still obvious, it isn't nearly as bad.

    Changing from Debug to Release mode doesn't seem to improve these ListBox and DropDownList delays on my Windows XP development machine.

    Hopefully this makes it easier to duplicate or narrow down the problem(s), but I'm not so sure they are entirely on the client side anymore.

    I just did some conditional pop-up dialogs based on the data, so I have a temporary workaround demonstration purposes, so I'm moving on to other things.

    Does anybody know if this is the best forum to be reporting Atlas bugs?

    Thanks,

    Dan


    Hi,

    you can report bugs in these forums or also in theMicrosoft Connect website.

    Thanks Garbin

    I added these two posts toMicrosoft Connect as:

    Atlas PartialRender CPU Bound/Slow with ListBoxes and DropDownLists

    https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=178704

    Atlas UpdatePanel Trigger for Visible/Hidden Controls

    https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=178708

    BTW - Like theAtlas Weblog a lot.

    Best Regards,

    Dan

  • DropDownList causes a full page postback instead of only updating the UpdatePanel

    I have a code for updating a DropDownList with items whenever another DropDownList triggers a SelectedIndexChanged event.

    When I select an item in the DDLSelect dropdown, it causes a full page postback instead of just updating the UpdatePanel. This problem only occurs when I try to implement it in an existing project, and it works fine when if I try it in a new project.

    I've updated my Web.config file to make my project compatible with AJAX, so I don't believe that's the problem.

    I should add that I'm trying to use this inside an ascx UserControl file, so maybe there are known issues there.

    Thanks in advance.

    Please post the usercontrol code

    OK, problem solved!

    It was the Web.config after all. I had this line which caused the problem:

    <

    xhtmlConformancemode="Legacy"/>

    I removed it and everything is fine.

    Cheers.