Showing posts with label dropdownlist. Show all posts
Showing posts with label dropdownlist. Show all posts

Wednesday, March 28, 2012

Dynamic generated Controls doesnt work, javascript error

I have an ajax enabled control which has a Dropdownlist that changes the Textbox when index gets changed. It is working fine if I use an ASPX page that contains the control in design time.

However, when I dynamically add this control to the ASPX in run time, I got an error when the Dropdownlist is triggered:

Javascript error: System.InvalidOperationException: A control with ID 'myDropDownList' could not be found for the trigger in UpdatePanel..etc..

What should I do? Please help..

There's a good chance that if you look at your page source you'll find that the dynamic control does not have a clientside Id of 'myDropDownList'. It'll probably have something more complex like ct100_myDropDownList or something.

Two possible fixes: 1) wire up your javascript on something other than the id (e.g. iterate over getElementsByTagName), or 2) render the control's ClientID inside a script tag on the page like: var ddl = '<%= myDropDownList.ClientID %>'

HOpe that helps.

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.

:)

Saturday, March 24, 2012

DropDownList1.SelectedValue allways the same on postbacks

Hi,

I'm new to Atlas/Ajax, so please forgive if this is a simple question.

I'm trying to create a simple solution, where I databinds a DropDownList and when the SelectedValue changes, a GridView must reflect the new data.

My problem is, when making the Ajax callback, the DropDownList.SelectedValue is always the same no matter what item is selected ind the DropDownList. Somehow the server does not know the new value.

Here's my code...

<formid="form1"runat="server">
<atlas:ScriptManagerID="ScriptManager1"EnablePartialRendering="true"runat="server"/>
<asp:DropDownListID="DropDownList1"runat="server"AutoPostBack="True"/>
<div>
<atlas:UpdatePanelID="aup"runat="server">
<ContentTemplate>
<asp:GridViewID="GridView1"runat="server"/>
</ContentTemplate>
<Triggers>
<atlas:ControlValueTriggerControlID="DropDownList1"PropertyName="SelectedValue"/>
</Triggers>
</atlas:UpdatePanel>
</div>
</form>

Here's my code behind...

Imports

System.Data

Partial

Class _Default
Inherits System.Web.UI.PageProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Load
Call GetDropDownItems()
EndSubProtectedSub DropDownList1_SelectedIndexChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles DropDownList1.SelectedIndexChanged
Call GetData()
EndSubPrivateSub GetDropDownItems()
Dim dtAs DataTable = .. get my DropDownList items as datatable
Me.DropDownList1.DataSource = dt
Me.DropDownList1.DataTextField ="text"
Me.DropDownList1.DataValueField ="ID"
Me.DropDownList1.DataBind()
EndSubPrivateSub GetData()
Dim dtAs DataTable = ... get data depending on theDropDownList1.SelectedValue <-- this is always the same!!
Me.GridView1.DataSource = dt
Me.GridView1.DataBind()
EndSub

End

Class

Hope you can help me out here.

Thanks!

M O J O

Sorry ... I found out the problem.

I just had to do this instead...

ProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Load
If Not Page.IsPostBack Then
Call GetDropDownItems()
End If
EndSub

Thanks anyway!!!

M O J O


Hi: Mojo

I had same problem, thank you for the hint.

Do you think why it happened, why Postback is important. Although it works, but I need to know why?

Will be great that you can give my some idea.

Thanks.

James


The reason is,

Whenever a DropDownList is databound, the SelectedValue is always cleared out. To prevent the users selection from getting cleared out, you would only databind the DDL on the first hit to the page (when it's not a PostBack). Then on subsequent PostBacks, you would not databind your DDL. The ListItems in the DDL will get restored to the control from ViewState and the users selection (as read from the forms Post data) will get set on the DDL control.


thanks, mbanavige, now i c

James

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.

Dropdownlist with non-selectable ListItems

Is it possible to use one of the toolkit controls to create a Dropdownlist containing ListItems that are selectable andnon-selectable? (i.e. hovering your mouse over thenon-selectable items doesn't highlight them and clicking on them does nothing - they are just there to group ListItems together).

Consider these 8 ListItems in a DropdownList:

-- Fruit --

Apple

Orange

Banana

-- Vegetables --

Carrot

Onion

Garlic

Using this hypothetical control, the ListItems "--Fruit--" and "--Vegetables--" would benon-selectable (and just there for grouping). All other listitems would be selectable.

How can I do this?

Hi,

Currently, this feature isn't available, you may submit a feature requesthere if you don't plan to implement it yourself.

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 with many entries is slow when EnablePartialRendering = true, but it is fast

Hello together,

I have a big performance problem when I use a DropDownList in an UpdatePanel. This is my code:

ASPX-Page:

<asp:ScriptManager ID="smMain" runat="server" EnablePartialRendering="true">
</asp:ScriptManager>
<asp:UpdatePanel ID="upPartial" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlList" runat="server" />
<asp:Button ID="btnPostBack" runat="server" Text="PostBack" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="progress" runat="server" DisplayAfter="0">
<ProgressTemplate>
Wait Please...
</ProgressTemplate>
</asp:UpdateProgress>

CodeBehind:

protected void Page_Load(object sender, EventArgs e)
{
for (int i = 0; i < 10000; i++)
{
((DropDownList)this.upPartial.FindControl("ddlList")).Items.Add(new ListItem("Value " + i.ToString(), i.ToString()));
}
}

When I click the button on this page it takes about 1 minute to complete the partial postback. But it is a simple postback with no other code to execute. When I set EnablePartialRendering = false in the ScriptManager the same postback executes in about 1 second.

Can somebody tell me what is the problem with the partial postpack?

Thanks and best regards

Gunther

Hi Gunther,

Well this is an issue that i have seen before on this forum. As far as i know you can't fix this when you take a look at the Ajax framwork. I think that a dropdownlist with 10000 rows isn't a very user friendly dropdownlist. Why are you putting so much items in 1 dropdownlist? Isn't possible to filter some of the items by the selection that a user can make in multiple dropdownlist. For example. If you have a dropdownlist with 10000 projectteams it could be possible to add a few selections before you select the project team like:

Select a Company

Select a Department

Select a Projectteam

This will filter the project team dropdownlist because you first selected a specific company and department so there are less projectteams left. I hope this helps

Regards,


Gunther,

Its not only the problem with the dropdown list, but also with gridview when i has more nubmer of rows.

when i removed the ajax controls, it worked fine.

sansav_p


Thank you for your answers.

The problem is that we are in a production environment, where I can't seperate the filter into several filters and I really need all the entries in the dropdownlist at the moment.

The thing I can't understand is why the page is fast without partial rendering and very very slow with partial rendering. I think I do nothing special and a solution for this should exist. Perhaps it can be solved with a dropdownlist from another vendor.

I will be happy with every solution or help I can get.

DropDownList using Atlas version 1.1

How can i implement atlas on dropdownlist using .net version 1.1. C#

If you're looking for the atlas client control, it's now called Microsoft.Preview.UI.Selector and resides in the Microsoft AJAX CTP.

As far as running atlas with .net 1.1, I believe you will only be able to use the client script and not the server portion.

DropdownList Update

Hi,

I have modified the sample program for Data Demo. I've used ASP.NET AJAX....I have a dropdownlist and a gridview inside an updatepanel. Also, im connected thru a objectdatasource. the dropdownlist gets value from objectdatasource1. The value comes from a distinct state from the author table while the gridview is connected to objectdatasource2. The value for objectdatasource2 comes from auther table where state = to the dropdownlist selected value.

Now what i want to achieve is that if i edit the state in the gridview my dropdownlist will be automacatically refresh. I tried adding <asp:AsyncPostBackTriggerControlID="GridView1"EventName="SelectedIndexChanged"/> to the updatepanel. I was able to save the changes but the dropdownlist doesnt.

Thanks

2lits

When both the controls that cause a refresh to the updatepanel are inside it, you can use the ChildrenAsTriggers property of the UpdatePanel. Set it to True, and your Dropdownlist should be re-binding.

Thanks


The ChildrenAsTriggers was already set to true but still my dropdownlist is not re-binding...any other thoughts? thanks!


Is your updateMode on conditional basis?

Thanks


it was set to always.

Thanks


I'd say step one is to remove the UpdatePanel and see if this is working in regular postback mode. If it is, then we need to figure out what's going wrong with your UpdatePanels.

I'd want to see some code at that point... is there just one UpdatePanel on the page? Is the GridView inside it? Is the DropDownList?


Yes There is only one Update Panel. The Gridview , dropdownlist, and the sources are inside it.

here's my code :

<formid="form1"runat="server"><asp:ScriptManagerID="ScriptManager1"runat="server"/> <divtitle="My First AJAX-Enabled Data Driven Page"><asp:UpdatePanelID="UpdatePanel1"runat="server"UpdateMode="Conditional"><ContentTemplate> <asp:DropDownListID="DropDownList1"runat="server"DataSourceID="ObjectDataSource1"DataTextField="State"DataValueField="State"AutoPostBack=True></asp:DropDownList><asp:GridViewID="GridView1"runat="server"AllowPaging="True"AutoGenerateColumns="False"DataSourceID="ObjectDataSource2"AllowSorting="True"DataKeyNames="AuthorID"><Columns><asp:CommandFieldShowEditButton="True"ShowSelectButton="True"/><asp:BoundFieldDataField="AuthorID"HeaderText="AuthorID"InsertVisible="False"ReadOnly="True"SortExpression="AuthorID"/><asp:BoundFieldDataField="FirstName"HeaderText="FirstName"SortExpression="FirstName"/><asp:BoundFieldDataField="LastName"HeaderText="LastName"SortExpression="LastName"/><asp:BoundFieldDataField="City"HeaderText="City"SortExpression="City"/><asp:BoundFieldDataField="State"HeaderText="State"SortExpression="State"/><asp:BoundFieldDataField="Zip"HeaderText="Zip"SortExpression="Zip"/><asp:BoundFieldDataField="Phone"HeaderText="Phone"SortExpression="Phone"/></Columns></asp:GridView><br/> <asp:ObjectDataSourceID="ObjectDataSource2"runat="server"OldValuesParameterFormatString="{0}"SelectMethod="GetData"TypeName="DataSet2TableAdapters.SelectAuthorsTableAdapter"UpdateMethod="Update"><SelectParameters><asp:ControlParameterControlID="DropDownList1"Name="State"PropertyName="SelectedValue"Type="String"/></SelectParameters><UpdateParameters><asp:ParameterName="AuthorID"Type="Int32"/><asp:ParameterName="FirstName"Type="String"/><asp:ParameterName="LastName"Type="String"/><asp:ParameterName="City"Type="String"/><asp:ParameterName="State"Type="String"/><asp:ParameterName="Zip"Type="String"/><asp:ParameterName="Phone"Type="String"/></UpdateParameters></asp:ObjectDataSource><asp:ObjectDataSourceID="ObjectDataSource1"runat="server"OldValuesParameterFormatString="original_{0}"SelectMethod="GetDataState"TypeName="DataSet2TableAdapters.StateListTableAdapter"></asp:ObjectDataSource><br/></ContentTemplate><Triggers><asp:AsyncPostBackTriggerControlID="DropDownList1"EventName="SelectedIndexChanged"/><asp:AsyncPostBackTriggerControlID="GridView1"EventName="RowUpdated"/></Triggers></asp:UpdatePanel> </div></form>
The updatemode is set to always. I just test it to conditional.

The updatemode is set to always. I just test it to conditional.

Thanks


And what's supposed to happen to the DropDownList when you edit the GridView?

Did you try removing the UpdatePanel? I have a feeling this isn't working with regular postbacks either and doesn't really have to do with AJAX, since your UpdatePanel code looks correct.


I should be able to see the updates in the state. example if I change the state from MI to NW upon save i should be able to see NW added in the dropdownlist. It is working on the regular postback...

Steve Marx:

I have a feeling this isn't working with regular postbacks either and doesn't really have to do with AJAX, since your UpdatePanel code looks correct.

This is to do with AJAX. When the DropDownList is binded declaratively, the list wont get refreshed on the triggers of the updatepanel. You need to explicitly bind the dropdownlist in the events specified on the updatepanel. But if have you had used the same ObjectSource for both the GridView and DropDownList, then sure the list gets updated.

Since the OP is working on the same database table, one ObjectDataSource is enough and when the GridView UpdateCommand is called, the data for the DropDownList is pulled again.

Thanks


e_screw, I don't quite understand... the databinding should work exactly the same way in a regular postback and an async postback. I'm still having trouble figuring out how this can work without the UpdatePanel but fail with it.

Certainly the DropDownList has to be bound again in the event handler, but what does that have to do with AJAX?


yes..thats also my understanding. How does the updatepanel rebind the data?

Thanks so much!


Steve Marx:

... the databinding should work exactly the same way in a regular postback and an async postback. I'm still having trouble figuring out how this can work without the UpdatePanel but fail with it. Certainly the DropDownList has to be bound again in the event handler, but what does that have to do with AJAX?

I am not sure though (still learning AJAX), the DataBinding of the controls (set declaratively using DataSourceID) will be started before the PreRender event of the page and not sure if the necessary client-scripts for that will be injected into the page by AJAX. I have checked with a different ObjectDataSource (each for Dropdownlist and GridView), and there was no client-script generated for the DropDownList unless there was explicit binding. When you are using the same ObjectDataSource for both the controls, there was client-script inject for both even if there was no explicit binding.

Thanks

DropDownList to DropDownList

I want to take the selected value of DropDownListA and based on that value do a query to the database and populate DropDownListB. For example, DropDownListA contains Entity values. If the user selects entity101 then I call stored procedure where I pass in the entity value, run a select statement and get a list of properties associated with the entity name. I want to take that list and populate DropDownListB. Easy enough to do with ASP.NET using the AutoPostBack. Would be real nice to do this with Atlas. Is it possible? If so, how?Atlas control toolkit has cascading dropdowns-please download the the controltoolkit and look at the sample application code for cascading dropdowns- that should help you,

Dropdownlist showing through Autocomplete in IE 6

Has anyone found a solution for preventing dropdownlists from showing through the Autocomplete dropdown in IE 6?

This is a well documented issue in IE5 and IE6. It was fixed finally fixed in IE7. In short, there is no way to fix it. You must redesign your page so they do not try to use the same area. I don't have the article handy, but it is due tothe fact the DDL is rendered by IE above the page itself.


Here is a link to read further about this:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1653209&SiteID=1


Thanks, unfortunately I will not be able to redesign the page. I just hope people stop using ie6 real soon

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 not fire (Autopostback - true!)

1<asp:DropDownList ID="SectionsDDL" runat="server" DataSourceID="SectionsObDS"2AutoPostBack="True" OnSelectedIndexChanged="SectionsDDL_SelectedIndexChanged"3DataTextField="titleName" DataValueField="id">4</asp:DropDownList>56<asp:UpdatePanel ID="UpdatePanel1" runat="server">7<ContentTemplate>8<asp:Panel ID="sectData" runat="server">9<asp:Label ID="tstlbl" runat="server" />10</asp:Panel>11</ContentTemplate>12<Triggers>13<asp:AsyncPostBackTrigger ControlID="sectionsDDL" EventName="SelectedIndexChanged" />14</Triggers>15</asp:UpdatePanel>

Everything is ok when I choose any item in DDL but first. When I choose first SelectedIndexChanged not fire.

I tried to find answer on forum and could not.

it sounds like your first item is selected when the dropdown loads so if you pick that answer the selected index never changes. Try adding an additional item called Not Selected or choos one or something along those lines as the first item in the list then everytime you should postback.

AjaxButter


Or you could change the SelectedIndex property to -1

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 Progress Bar - Very Large amount of data

I was wondering how to go about simulating a quick load of a page with AJAX. It takes 10 seconds to populate a huge dropdownlist (large size required). So I have a page that is blank for 10 seconds before showing any activity. The dropdownlist is populated using a code behind procedure calling an SQL 2005 DB SP.

Is it possible to load the page then fill the dropdown list with a progress indicator. (Or just an overall page loading indicator) I'd really appreciate any ideas or examples as I'm a wee bit mentally fatigued tonight :/. Thanks in advanced!

You can use?an asp:UpdatePanel?with?an?asp:UpdateProgress?to?load?data?from?database?and?fill?in?the?asp:DropDownList.
Here?are?some?sample?codes?for?your?reference.
<asp:UpdateProgress ID="UpdateProgress1" Visible="true" DisplayAfter="1" runat="server" AssociatedUpdatePanelID="udpUpperRight">
<ProgressTemplate>
????Loading...
</ProgressTemplate>
</asp:UpdateProgress
<table width="100%">
<tr>
<td valign="top">
<asp:PlaceHolder ID="pnlUpperLeft" runat="server"></asp:PlaceHolder>
</td>
<td style="width: 8px"></td>
<td>
<asp:UpdatePanel ID="udpUpperRight" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:Label ID="lblDisply" runat="server" Text="This is asp:UpdateProgress testing"></asp:Label>
<br />
<asp:Image ID="img" runat="server" ImageUrl="~/images/Amazon.gif" />
<asp:Button ID="btnUpdate" runat="server" Text="Update Progress" OnClick="btnUpdate_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table
Behind Code:
protected void btnUpdate_Click(object sender, EventArgs e)
{
????//Load data from database and fill out the asp:DropDownList
}

Wish?the?above?can?help?you.

Cool thanks Ji!

You've certainly opened up my eyes to more features of the update panel. Cheers!

I'm guessing I should substitute in a dropdown where the image is. Is there a way perform the button click coded behind at load? Either way I will experiment. Thanks for the help.

DropDownList problem with ATLAS

Excuse-me for my poor english.

This is my code:

<

atlas:ScriptManagerID="smImmobili"runat="server"EnablePartialRendering="true"/>

<

atlas:UpdatePanelID="upProvinciaZona"runat="server"EnableViewState="True"RenderMode="Inline">

<ContentTemplate>

<tableborder="0"cellpadding="0"cellspacing="4"style="width: 98%"><tr><tdstyle="width: 109px"><strong>

Regione

</strong></td><tdcolspan="3"><asp:DropDownListID="cmbRegioni"runat="server"Width="190px"AutoPostBack="True"OnSelectedIndexChanged="cmbRegioni_SelectedIndexChanged"CssClass="Testo"></asp:DropDownList></td>

</tr><tr><tdstyle="width: 109px; height: 19px;"><strong>

Provincia

</strong></td><tdcolspan="3"style="height: 19px"><asp:DropDownListID="cmbProvince"runat="server"Width="190px"AutoPostBack="True"OnSelectedIndexChanged="cmbProvince_SelectedIndexChanged"EnableTheming="True"CssClass="Testo"></asp:DropDownList><strong></strong></td></tr>

<%

if(_ViewZone){ %><tr><tdstyle="width: 109px; height: 19px"><strong>Zona</strong></td><tdcolspan="3"style="height: 19px"><asp:DropDownListID="cmbZone"runat="server"Width="190px"CssClass="Testo"></asp:DropDownList></td></tr>

<%} %>

<trbgcolor="#044da4"><tdcolspan="4"style="height: 15px"></td></tr></table></ContentTemplate></atlas:UpdatePanel>

This is a "CascadingDropDownList Style" page, obiouvsly not from Atlas Toolkit.

On SelectedIndexChange Event on first dropdown I execute server side code to Fill the second drop down:

protected

void cmbRegioni_SelectedIndexChanged(object sender,EventArgs e)

{

FillComboProvince(

int.Parse(cmbRegioni.SelectedValue));

_ViewZone =

clsProvince.getProvince(cmbProvince.SelectedValue).ViewZone;

}

FillComboProvince is a Method that fill my combo with some cities.

ex... cmbProvince.Items.add(...)...

With EnablePartialRendering="true" don't work! WHY?

Is it a bug?

hello.

can you give us more details about what's wrong? btw, if you can build a small page that reprocudes the problem and post it here, you'll have more options of getting an answer...

DropdownList OnSelectedIndexChanged event within ModalPopupExtender

I have aModalPopupExtender with two DropdownLists. I want to populate the second dropdownlist dynamically base on the user selection in the first dropdownlist. Once user selects values from both dropdown lists, then I want to postback the entire page.

But the OnSelectedIndexChanged event of the dropdownlist is not firing whenever the selection is changed.

Is this possible withinModalPopupExtender? Appreciate your help.

You may want AutoPostBack="true" and an UpdatePanel.

Dropdownlist not working within an UpdatePanel

I have a MasterPage with a ScriptManager EnablePartialRendering set to true.

On my AddDeceseadInfo.aspx page I have multipe textboxes and a dropdownlist all wrapped in a UpdatePanel. Also on the AddDeceasedInfo.aspx page (content) I have a ProxyScriptManager.

When I pick a value from the Dropdownlist the value is always "".

When I set AutoPostBack to true my ValidationControl fires and tells me the dropdownlist can not be empty which at that point it is.

When I set the AutoPostBack to false once a pick a value from the dropdownlist all the data in the dropdownlist disappears.

Can somebody help out a AJAX newbie............Cheers!

protectedvoid Page_Load(object sender,EventArgs e)

{

TextBoxFirstName.Focus();

if (!IsPostBack)

{

//Gets the languageID for the current user.

int languageID =LanguageUtility.GetLanguageIDByTwoLetterISOLanguageName();

DropDownListCauseOfDeath.DataSource = BLL.CauseOfDeath.GetCausesOfDeathByLanguageID(languageID);

//The field in the data source which provides the item text.

DropDownListCauseOfDeath.DataTextField ="CauseOfDeath";DropDownListCauseOfDeath.DataValueField ="CauseOfDeathID";

DropDownListCauseOfDeath.DataBind();

}

}

protectedvoid ButtonReset_Click(object sender,EventArgs e)

{

Utility.WebUtility.ClearAllTextBoxes(this);

}

protectedvoid ButtonSubmit_Click(object sender,EventArgs e)

{

if (Page.IsValid)

{

string firstName =HttpUtility.HtmlEncode(TextBoxFirstName.Text).Trim();

string middleName =HttpUtility.HtmlEncode(TextBoxMiddleName.Text).Trim();

string lastName =HttpUtility.HtmlEncode(TextBoxLastName.Text).Trim();

string nickName =HttpUtility.HtmlEncode(TextBoxNickName.Text).Trim();

DateTime dateOfBirth =Convert.ToDateTime(HttpUtility.HtmlEncode(TextBoxDateOfBirth.Text).Trim());

DateTime dateOfDeath =Convert.ToDateTime(HttpUtility.HtmlEncode(TextBoxDateOfDeath.Text).Trim());

int causeOfDeathID =Convert.ToInt32(DropDownListCauseOfDeath.SelectedValue);string birthPlace =HttpUtility.HtmlEncode(TextBoxBirthPlace.Text).Trim();

}

else

{

}

}

}

Set AutoPostBack to true and also set CauseValidation property to false


Set the EnableClientScript property to false on your validation control. Validators aren't supported in an UpdatePanel, this may be causing you issues,see Item #4 for more information

-Damien


I guess my post was not clear but the answers posted did not really help. My DropDownList is inside an UpdatePanel.

The ScriptManager is set to enable patial rendering.

AutoPostBack is set to true.

My UpdatePanel has UpdateMode set to Conditional

I populate the DropDownList with values from my database. When the page loads the values are there in the DropDownList. When I go and pick a value the data from the DropDownList disappears. Basically I end up with a empty DropDownList. Values gone................

When I set the AutoPostBack property to false the data stays in the DropDownList after I pick a value but when I hit the submit button the Validation control fires because the DropDownList is all of a sudden empty again.

I am running the latest Versions of ASP.Net Ajax and was under the impress the validator problems have been solved in the latest version. It seems to work on all my other froms that I use the UpdatePanel. The Validator controls and UpdatePanel work nicely together.

There seem to be no examples on the web where somebody has on DropDownList in an UpdatePanel and simple wants to get the value from that DropDownList and the additional TextBoxes once the Submit button is clicked.

I watched some of the ASP.Net videos and there are some Extenders that might be useful but it is too much work. Isn't there a why of making a simple DropDownList work within a UpdatePanel. So I can get the value from it.


How are you binding the list; are you possibly clearing it on the postback? Do you have ViewState enabled for the DropDownList?

Also, I'm using a DropDownList in an UpdatePanel successfully so it does work.

-Damien


Thanks for your reply, here is my Page_Load

protectedvoid Page_Load(object sender,EventArgs e)

{

TextBoxFirstName.Focus();

if (!IsPostBack)

{

//Gets the languageID for the current user.

int languageID =LanguageUtility.GetLanguageIDByTwoLetterISOLanguageName();

DropDownListCauseOfDeath.DataSource = BLL.CauseOfDeath.GetCausesOfDeathByLanguageID(languageID);

//The field in the data source which provides the item text.

DropDownListCauseOfDeath.DataTextField ="CauseOfDeath";DropDownListCauseOfDeath.DataValueField ="CauseOfDeathID";

DropDownListCauseOfDeath.DataBind();

}

}


If I comment if(!Ispostback) out then the form works as it should the only problem is the that the DropDownList gets bound again after I hit the submit button and therefore the the ID returned by the DropDownList is always 1. Somebody it sitting on my brain and I can't figure this out. Any ideas? Thanks, Newbie

protectedvoid Page_Load(object sender,EventArgs e)

{

TextBoxFirstName.Focus();

//if (!IsPostBack)

//{

//Gets the languageID for the current user.

int languageID =LanguageUtility.GetLanguageIDByTwoLetterISOLanguageName();

DropDownListCauseOfDeath.DataSource = BLL.CauseOfDeath.GetCausesOfDeathByLanguageID(languageID);

//The field in the data source which provides the item text.

DropDownListCauseOfDeath.DataTextField ="CauseOfDeath";DropDownListCauseOfDeath.DataValueField ="CauseOfDeathID";

DropDownListCauseOfDeath.DataBind();

//}

}


Just fixed the problem. I overrode the OnInit event like this

protectedoverridevoid OnInit(EventArgs e)

{

base.OnInit(e);

PopulateDropDownList();

}

and added a PopulateDropDownList() method

privatevoid PopulateDropDownList()

{

//Gets the languageID for the current user.

int languageID =LanguageUtility.GetLanguageIDByTwoLetterISOLanguageName();

DropDownListCauseOfDeath.DataSource = BLL.CauseOfDeath.GetCausesOfDeathByLanguageID(languageID);

//The field in the data source which provides the item text.

DropDownListCauseOfDeath.DataTextField ="CauseOfDeath";DropDownListCauseOfDeath.DataValueField ="CauseOfDeathID";

DropDownListCauseOfDeath.DataBind();

}

Set the AutoPostBack to false

EnableViewState to true

UpdatePanel to Conditional

ScriptManager EnablePartialRendering to true

And it is all working now like a charm. DropDownList works in UpdatePanel and so do the validation controls. Thanks Microsoft.....................


Thank you for posting the solution. You just made my day!

Dropdownlist is flickering During Asynchronous Postback

I have placed dropdownlist along with some other controls in an Update panel.During Async Postback, the dropdownlist is flickering. Can any one help me to avoid the flickering of Dropdownlist

Anything in the update panel may flicker. If you don't want something to, you may want to take it out of the update panel. You can use it as a trigger if you are changing something based of the selected index when it changes.

I have noticed this as well. I tried to figure it out for a day or so and I'm taking a break from it. Hopefully someone will answer.

I don't see this behaviour with text boxes though...


It could also be more noticeable if you have a large number of items in the dropdown and more noticeable if they are bound to it. As I said in my previous reply, you can remove it from the update panel if you do not need to change the dropdown's contents by placing it outside the update panel.

DropDownList inside UpdatePanel Performance Issue (IE7 vs. FireFox)

hey,

I have a weird performance issue that i just don't know how to explain:

I built a simple page that has a dropdownlist and a button controls, both of them are inside an update panel.

When a user clicks on the button for the first time, it loads the dropdownlist with 2000 items (just for testing purposes). On the second click, it clears the dropdownlist and fill it with only 2 items. The code is very simple. All in the code behind

I tried the page on IE7 and FireFox. In IE7: the page pauses on the second load (the clear of the 2000 items and the load of the 2 items), while firefox is so much faster.

I removed the update panel and tried the page again, its fast on both IE7 and FireFox. Also tried to add some javascript code to clear the list on the client side, its also too slow.

Does anyone knows a way how to improve it on IE7 :) beside uninstalling it and use FireFox instead :)


thnx 4 ur time

Honestly, I had a lot of performance issues with IE with several of the AJAX controls. We ended up buying a product that is much better than the free one.


i've never seen a dropdownlist that has 2000 items in it before.

what you might want to do is categorizing the items into group(s) and use 2 or more dropdownlist(s). definitely will increase your performance.


Thanks 4 the reply. But its not just about 2000 items, even if you make them 1000 (unfortunately, this is the business logic, that i have to display all the items). Why does FireFox is so much faster, is there something i can do to optimize it.

Thanks