Showing posts with label second. Show all posts
Showing posts with label second. Show all posts

Saturday, March 24, 2012

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 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 inside UpdatePanel

Dear All,

I have two DropDownList inside an UpdatePanel.

When I refresh the updatepanel the two DropDownList disappare for few second's, can I avoid it ?

Hi,

did you set the EnablePartialRendering attribute of the ScriptManager to "true"? If so, could you post the relevant code?

Yes EnablePartialRendering is set to true.

this is the code :

<%@. Page Language="VB" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %>

<script runat="server">


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If Page.IsValid Then
If Page.IsValid Then


Dim stemp() As String
Dim ds As New WSUniprof.DScliente

Dim myrow As WSUniprof.DScliente.clienteRow = ds.cliente.NewclienteRow

myrow.Anagrafica = Me.TXRagioneSociale.Text.ToUpper.Trim
myrow.PartitaIva = Me.TXPartitaIva.Text.Trim
myrow.Indirizzo = Me.TXSedeLegale.Text.Trim

stemp = Me.DropDownList2.SelectedValue.Split("/")
If IsNumeric(stemp(0)) Then myrow.IDComune = stemp(0)

myrow.Cap = Me.TXCap.Text.ToString.Trim
myrow.Telefono = Me.TXTelefono.Text.ToString.Trim
myrow.Fax = Me.TXFax.Text.ToString.Trim
myrow.AltriTelefoni = Me.TXCellulare.Text.ToString.Trim
myrow.EMailInternet = Me.TXEmail.Text.Trim
myrow.IndirizzoS = Me.TXIndirizzoScarico.Text.Trim

stemp = Me.DropDownList4.SelectedValue.Split("/")
If IsNumeric(stemp(0)) Then myrow.IDComuneS = stemp(0)

myrow.CapS = Me.TXCapScarico.Text.ToString.Trim
myrow.TelefonoS = Me.TXTelefonoScarico.Text.ToString.Trim
myrow.FaxS = Me.TXFaxScarico.Text.ToString.Trim

ds.cliente.AddclienteRow(myrow)

Dim WEBserv As New WSUniprof.ClassCliente
' If WEBserv.IserimentoCliente(ds, Session("IDAnagrafica"), "malbec10") > 0 Then
Me.BloccaControlli()
Me.LabelCodiceCliente.Visible = True
Me.TXCodiceCliente.Visible = True
Me.TXCodiceCliente.Text = "12321"
System.Threading.Thread.Sleep(3000)
'Else

' End If

'SE PROVIENE DALLA PAGINA DI INSERIMENTO ORDINE
' If Request.QueryString("fromOrd") = "1" Then
'Response.Redirect("infoOrdine.aspx", False)
' Else
' Response.Redirect("default.aspx", False)
' End If
End If
End If
End Sub

Private Sub BloccaControlli()
Me.TXCap.Enabled = False
Me.TXCapScarico.Enabled = False
Me.TXCellulare.Enabled = False
Me.TXEmail.Enabled = False
Me.TXFax.Enabled = False
Me.TXFaxScarico.Enabled = False
Me.TXIndirizzoScarico.Enabled = False
Me.TXPartitaIva.Enabled = False
Me.TXPartitaIva.Enabled = False
Me.TXRagioneSociale.Enabled = False
Me.TXSedeLegale.Enabled = False
Me.TXRagioneSociale.Enabled = False
Me.TXSedeLegale.Enabled = False
Me.TXTelefono.Enabled = False
Me.TXTelefonoScarico.Enabled = False
Me.DropDownList1.Enabled = False
Me.DropDownList2.Enabled = False
Me.DropDownList3.Enabled = False
Me.DropDownList4.Enabled = False
Me.Label1.Enabled = False
Me.Label2.Enabled = False
Me.Label3.Enabled = False
Me.Label4.Enabled = False
Me.Label5.Enabled = False
Me.Label6.Enabled = False
Me.Label7.Enabled = False
Me.Label8.Enabled = False
Me.Label9.Enabled = False
Me.Label10.Enabled = False
Me.Label11.Enabled = False
Me.Label12.Enabled = False
Me.Label13.Enabled = False
Me.Label14.Enabled = False
Me.Label16.Enabled = False
Me.Label17.Enabled = False
Me.Label18.Enabled = False


End Sub
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script language="javascript" type="text/javascript">
function StartInsert(){
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false){
$('ctl00$ContentPlaceHolder1$Button1').disabled = true;
}

}
</script>
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 15px">
<tr>
<td align="center" style="width: 100%; height: 15px">
<asp:Label ID="Label1" runat="server" Text="Inserimento nuovo cliente"></asp:Label></td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 400px">
<tr>
<td align="center" style="width: 100%; padding-top: 15px" valign="top">
<atlas:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table border="0" cellpadding="0" cellspacing="0" style="width: 400px; height: 300px; border-right: activeborder 1px solid; border-top: activeborder 1px solid; border-left: activeborder 1px solid; border-bottom: activeborder 1px solid;">
<tr>
<td style="width: 200px; height: 15px" align="right">
<asp:Label ID="Label2" runat="server" Text="Ragione sociale"></asp:Label></td>
<td align="left" colspan="2" style="height: 15px">
<asp:TextBox ID="TXRagioneSociale" runat="server" Width="296px"></asp:TextBox></td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
</td>
<td align="left" colspan="2" style="height: 15px">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TXRagioneSociale"
Display="Dynamic" ErrorMessage="Ragione sociale richiesta"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 200px; height: 15px" align="right">
<asp:Label ID="Label3" runat="server" Text="Sede legale"></asp:Label></td>
<td align="left" colspan="2" style="height: 15px">
<asp:TextBox ID="TXSedeLegale" runat="server" Width="296px"></asp:TextBox></td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
</td>
<td align="left" colspan="2" style="height: 15px">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TXSedeLegale"
Display="Dynamic" ErrorMessage="Indirizzo sede legale richiesto"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 200px; height: 15px" align="right">
<asp:Label ID="Label4" runat="server" Text="C.A.P."></asp:Label></td>
<td align="left" colspan="2" style="height: 15px">
<asp:TextBox ID="TXCap" runat="server" Width="80px"></asp:TextBox></td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
</td>
<td align="left" colspan="2" style="height: 15px">
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TXCap"
Display="Dynamic" ErrorMessage="Codice di avviamento postale richiesto"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 200px; height: 15px" align="right">
<asp:Label ID="Label5" runat="server" Text="Provincia"></asp:Label></td>
<td align="left" colspan="2" style="height: 15px">
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="ProvinciaDataSource"
DataTextField="NomeProvincia" DataValueField="IDProvincia">
<asp:ListItem Selected="True">Selezionare una provincia</asp:ListItem>
</asp:DropDownList>
<asp:ObjectDataSource ID="ProvinciaDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetData" TypeName="DataSet1TableAdapters.ProvinciaTableAdapter"></asp:ObjectDataSource>
</td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
</td>
<td align="left" colspan="2" style="height: 15px">
</td>
</tr>
<tr>
<td style="width: 200px; height: 15px" align="right">
<asp:Label ID="Label6" runat="server" Text="Comune"></asp:Label></td>
<td align="left" colspan="2" style="height: 15px">
<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="ComuneDataSource"
DataTextField="Comune" DataValueField="IDComune">
</asp:DropDownList>
<asp:ObjectDataSource ID="ComuneDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetData" TypeName="DataSet1TableAdapters.ComuneTableAdapter">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="IDProvincia" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
</td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
</td>
<td align="left" colspan="2" style="height: 15px">
</td>
</tr>
<tr>
<td style="width: 200px; height: 15px" align="right">
<asp:Label ID="Label7" runat="server" Text="Partita IVA"></asp:Label></td>
<td align="left" colspan="2" style="height: 15px">
<asp:TextBox ID="TXPartitaIva" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
</td>
<td align="left" colspan="2" style="height: 15px">
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TXPartitaIva"
Display="Dynamic" ErrorMessage="La partita IVA è incorretta" SetFocusOnError="True"
ValidationExpression="\d{11}"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td style="width: 200px; height: 15px" align="right">
<asp:Label ID="Label8" runat="server" Text="Telefono"></asp:Label></td>
<td align="left" colspan="2" style="height: 15px">
<asp:TextBox ID="TXTelefono" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
</td>
<td align="left" colspan="2" style="height: 15px">
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="TXTelefono"
ErrorMessage="Il numero di telefono è richiesto"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 200px; height: 15px" align="right">
<asp:Label ID="Label9" runat="server" Text="Fax"></asp:Label></td>
<td align="left" colspan="2" style="height: 15px">
<asp:TextBox ID="TXFax" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
</td>
<td align="left" colspan="2" style="height: 15px">
</td>
</tr>
<tr>
<td style="width: 200px; height: 15px" align="right">
<asp:Label ID="Label10" runat="server" Text="Cellulare"></asp:Label></td>
<td align="left" colspan="2" style="height: 15px">
<asp:TextBox ID="TXCellulare" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 200px; height: 15px" align="right">
</td>
<td align="left" colspan="2" style="height: 15px">
</td>
</tr>
<tr>
<td style="width: 200px; height: 15px" align="right">
<asp:Label ID="Label11" runat="server" Text="E-mail"></asp:Label></td>
<td align="left" colspan="2" style="height: 15px">
<asp:TextBox ID="TXEmail" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
</td>
<td align="left" colspan="2" style="height: 15px">
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="TXEmail"
EnableViewState="False" ErrorMessage="L'indirizzo E-mail inserito non è corretto"
SetFocusOnError="True" ValidationExpression="\w+([-+.']\w+)*@.\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td align="left" colspan="3" style="height: 15px; background-color: buttonface">
<asp:Label ID="Label12" runat="server" Text="Luogo di scarico (non obbligatorio)"></asp:Label></td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
<asp:Label ID="Label13" runat="server" Text="Indirizzo"></asp:Label></td>
<td align="left" colspan="2" style="height: 15px">
<asp:TextBox ID="TXIndirizzoScarico" runat="server" Width="296px"></asp:TextBox></td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
</td>
<td align="left" colspan="2" style="height: 15px">
</td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
<asp:Label ID="Label14" runat="server" Text="Provincia"></asp:Label></td>
<td align="left" colspan="2" style="height: 15px">
<asp:DropDownList ID="DropDownList3" runat="server" AutoPostBack="True" DataSourceID="ProvinciaDataSource"
DataTextField="NomeProvincia" DataValueField="IDProvincia">
<asp:ListItem Selected="True">Selezionare una provincia</asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
</td>
<td align="left" colspan="2" style="height: 15px">
</td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
<asp:Label ID="Label15" runat="server" Text="Comune"></asp:Label></td>
<td align="left" colspan="2" style="height: 15px">
<asp:DropDownList ID="DropDownList4" runat="server" AutoPostBack="True" DataSourceID="ComuneScaricoDataSource"
DataTextField="Comune" DataValueField="IDComune">
<asp:ListItem Selected="True">Selezionare una provincia</asp:ListItem>
</asp:DropDownList>
<asp:ObjectDataSource ID="ComuneScaricoDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetData" TypeName="DataSet1TableAdapters.ComuneTableAdapter">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList3" Name="IDProvincia" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
</td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
<asp:Label ID="Label18" runat="server" Text="C.A.P."></asp:Label></td>
<td align="left" colspan="2" style="height: 15px">
<asp:TextBox ID="TXCapScarico" runat="server" Width="80px"></asp:TextBox></td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
</td>
<td align="left" colspan="2" style="height: 15px">
</td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
<asp:Label ID="Label16" runat="server" Text="Telefono"></asp:Label></td>
<td align="left" colspan="2" style="height: 15px">
<asp:TextBox ID="TXTelefonoScarico" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
</td>
<td align="left" colspan="2" style="height: 15px">
</td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
<asp:Label ID="Label17" runat="server" Text="Fax"></asp:Label></td>
<td align="left" colspan="2" style="height: 15px">
<asp:TextBox ID="TXFaxScarico" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
</td>
<td align="left" colspan="2" style="height: 15px">
</td>
</tr>
<tr>
<td align="right" style="width: 200px; height: 15px">
<asp:Label ID="LabelCodiceCliente" runat="server" Text="Codice cliente" Visible="False"></asp:Label></td>
<td align="left" colspan="2" style="height: 15px">
<asp:TextBox ID="TXCodiceCliente" runat="server" Visible="False"></asp:TextBox></td>
</tr>
<tr>
<td align="left" colspan="3" style="height: 15px">
</td>
</tr>
<tr>
<td style="width: 200px; height: 15px" align="right">
</td>
<td style="width: 200px; height: 15px">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" OnClientClick="StartInsert();"
Text="Inserisci cliente" /></td>
<td style="width: 200px; height: 15px">
</td>
</tr>
</table>
</ContentTemplate>
</atlas:UpdatePanel>

<atlas:UpdateProgress ID="updateProgress1" runat="server">
<ProgressTemplate>
<table style="position: absolute; top: 100px; left: 50%; margin: 0px -100px; z-index: 4;
border-right: appworkspace thin solid; border-top: appworkspace thin solid; border-left: appworkspace thin solid;
border-bottom: appworkspace thin solid; background-color: inactivecaptiontext;
width: 200px;">
<tr>
<td style="font-family: Verdana; font-weight: bold; font-size: 10px; color: maroon;">
<img alt="" src="http://pics.10026.com/?src=images/spinner.gif" />
Contacting Server...
<button id="abortButton">
Stop</button>
</td>
</tr>
</table>
</ProgressTemplate>
</atlas:UpdateProgress>
</td>
</tr>
</table>
</asp:Content>


hiya,

I think using the Atlas UpdateProgress thing "which comes with Jan release" would help. Try to use it

Thanks,


I am using Jenuary release.

if I see the page with IE7 that is very nice, no refresh but with ie6 is very bad.


What's the purpose of the following line from your code? Doesn't this force 3 seconds of pause that you've mentioned?

System.Threading.Thread.Sleep(3000)

Ciao,

I use the System.Threading.Thread.Sleep(3000) just to simulate the insert into database.

Wednesday, March 21, 2012

DropDownList flashing when inside an UpdatePanel

Hi,

Does anyone know why the second DropDownList in the following code 'flashes' when the selection is changed in the first one? - and how I can prevent this?

<atlas:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"/>

<asp:DropDownListID="DropDownList1"runat="server"AutoPostBack="true">

<asp:ListItem>One</asp:ListItem>

<asp:ListItem>Two</asp:ListItem>

<asp:ListItem>Three</asp:ListItem>

</asp:DropDownList>

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

<Triggers>

<atlas:ControlEventTriggerControlID="DropDownList1"EventName="SelectedIndexChanged"/>

</Triggers>

<ContentTemplate>

<asp:DropDownListID="DropDownList2"runat="server"AutoPostBack="true">

<asp:ListItem>Flashing option one</asp:ListItem>

<asp:ListItem>Flashing option two</asp:ListItem>

<asp:ListItem>Flashing option three</asp:ListItem>

</asp:DropDownList>

</ContentTemplate>

</atlas:UpdatePanel>

I believe you need to put the first drop down list in an update panel too. Also set to conditional and without any triggers.

<atlas:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"/>

<atlas:UpdatePanelID="UpdatePanel1"Mode="Conditional"runat="server">
<ContentTemplate>
<asp:DropDownListID="DropDownList1"runat="server"AutoPostBack="true">
<asp:ListItem>One</asp:ListItem>
<asp:ListItem>Two</asp:ListItem>
<asp:ListItem>Three</asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
</atlas:UpdatePanel>

<atlas:UpdatePanelID="UpdatePanel2"Mode="Conditional"runat="server">
<Triggers>
<atlas:ControlEventTriggerControlID="DropDownList1"EventName="SelectedIndexChanged"/>
</Triggers>
<ContentTemplate>
<asp:DropDownListID="DropDownList2"runat="server"AutoPostBack="true">
<asp:ListItem>Flashing option one</asp:ListItem>
<asp:ListItem>Flashing option two</asp:ListItem>
<asp:ListItem>Flashing option three</asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
</atlas:UpdatePanel>


Many thanks for the reply, but unfortunately I still got the same problem with your fix - however - I have since downloaded Internet Explorer 7 beta 2 and the problem has gone away with that...

Thanks,

Keith


I'm having the same problem - I have a drop down that populates the Gridview depending on the selected value. I have tried the suggested soultion with a UpdatePanel control around my drop down list and another around my GridView.

Anyone have any other suggestions other than to try IE 7?

Thanks
I am having the same problem. The problemgoes away in IE 7. I think the problem is with only drop down list andlistbox control. All other other control like textboxes do not flash.As far i know drop down and listbox are not rendered in the same wayhas textboxes...i can think it has to do with IE6...i may be wrong...

Murali

For me, this flicker only occurs on pages that have a Flash movie embedded in the page. I am using the Cascading Drop Down from the Atlas Control Toolkit and everywhere that there is a flash movie, I get the flicker, if I remove the movie, the flicker goes away.

Any thoughts?


Hi, here it happen the same...dropdown and listitem refresh on IE6....

really dont know why it happens on microsoft browser and not happen on firefox....

anyone knows how to fiz it on IE6? i cant find a way.

Has anyone found a way to solve this with IE6?

As long as they are outside of the UpdatePanel it works fine.


From what I've seen and read no... At least not that I've found.


Does anybody know if this issue been resolved in CTP july release

Thanks

Murali Bala


Hi,

DropDownList And ListBox are windows controls, so there is no way to stop this flicker unless MS themselves release some patch for pre-IE7 browsers. If you notice...No HTML control can draw over a DropdownList.