I have a simple WebDropDown control that I use to select a direction. If I type in a direction and wait half a section, the current value is getting set so I can see it in the CurrentValue property on postback. The problem is that if I'm tabbing through fields and type a direction and hit tab quick enough, I see the text I typed in there but the CurrentValue property on postback is an empty string. How can I get the value that's been typed into the dropdown? Here's my dropdown of directions.
<
ig:WebDropDown ID="cboAnimalStreetDir" runat="server" Width="60">
<Items>
Sure. I posted the definition for the WebDropDown above but here's the entire panel that it resides in including the button and the button click code:
<asp:Panel runat="server" ID="pnlNew" Visible="false"> <div id="divAddress" runat="server"> <table class="StyledTable"> <tr> <td align="center" style="width: 100%; padding:5px;" colspan="2"> <asp:Label ID="lblAddress" runat="server" Font-Bold="True" Width="100%" Text="Address"></asp:Label> </td> </tr> <tr> <td style="width:30%;padding:5px;text-align:right;"><asp:Label ID="lblStreetNum" runat="server" Text="Street #: *" ForeColor="Red"></asp:Label></td> <td style="padding:5px;"> <ig:WebTextEditor ID="txtStreetNum" runat="server" FocusOnInitialization="true" MaxLength="6" Width="50" CssClass="StyledText" /> </td> </tr> <tr> <td style="width:30%;padding:5px;text-align:right;"><asp:Label ID="lblStreetNumSufix" runat="server" Text="Suffix:"></asp:Label></td> <td style="padding:5px;"> <ig:WebTextEditor ID="txtStreetNumSuffix" runat="server" MaxLength="8" Width="60" CssClass="StyledText" /> </td> </tr> <tr> <td style="width:30%;padding:5px;text-align:right;"><asp:Label ID="lblStreetDir" runat="server" Text="Direction:"></asp:Label></td> <td style="padding:5px;"> <ig:WebDropDown ID="cboStreetDir" runat="server" Width="60"> <Items> <ig:DropDownItem Text="" Value="" /> <ig:DropDownItem Text="N" Value="N" /> <ig:DropDownItem Text="S" Value="S" /> <ig:DropDownItem Text="E" Value="E" /> <ig:DropDownItem Text="W" Value="W" /> <ig:DropDownItem Text="NE" Value="NE" /> <ig:DropDownItem Text="NW" Value="NW" /> <ig:DropDownItem Text="SE" Value="SE" /> <ig:DropDownItem Text="SW" Value="SW" /> </Items> </ig:WebDropDown> </td> </tr> <tr> <td style="width:30%;padding:5px;text-align:right;"><asp:Label ID="lblStreetName" runat="server" Text="Street Name: *" ForeColor="Red"></asp:Label></td> <td style="padding:5px;"> <ig:WebTextEditor ID="txtStreetName" runat="server" MaxLength="25" Width="200" CssClass="StyledText" /> </td> </tr> <tr> <td style="width:30%;padding:5px;text-align:right;"><asp:Label ID="lblStreetType" runat="server" Text="Street Type: *" ForeColor="Red"></asp:Label></td> <td style="padding:5px;"> <ig:WebTextEditor ID="txtStreetType" runat="server" MaxLength="4" Width="40" CssClass="StyledText" /> </td> </tr> <tr> <td style="width:30%;padding:5px;text-align:right;"><asp:Label ID="lblAptNum" runat="server" Text="Appartment:"></asp:Label></td> <td style="padding:5px;"> <ig:WebTextEditor ID="txtAptNum" runat="server" MaxLength="12" Width="100" CssClass="StyledText"/> </td> </tr> <tr> <td style="width:30%;padding:5px;text-align:right;"><asp:Label ID="lblAddrLine2" runat="server" Text="Address Line 2:"></asp:Label></td> <td style="padding:5px;"> <ig:WebTextEditor ID="txtAddrLine2" runat="server" MaxLength="40" Width="300" CssClass="StyledText" /> </td> </tr> <tr> <td style="width:30%;padding:5px;text-align:right;"><asp:Label ID="lblCity" runat="server" Text="City: *" ForeColor="Red"></asp:Label></td> <td style="padding:5px;"> <ig:WebTextEditor ID="txtCity" runat="server" MaxLength="25" Width="200" CssClass="StyledText" /> </td> </tr> <tr> <td style="width:30%;padding:5px;text-align:right;"><asp:Label ID="lblState" runat="server" Text="State: *" ForeColor="Red"></asp:Label></td> <td style="padding:5px;"> <ig:WebDropDown ID="cboState" runat="server" Width="60" CurrentValue="WA"> <Items> <ig:DropDownItem Text="AK" Value="AK" /> <ig:DropDownItem Text="AL" Value="AL" /> <ig:DropDownItem Text="AZ" Value="AZ" /> <ig:DropDownItem Text="CA" Value="CA" /> <ig:DropDownItem Text="CO" Value="CO" /> <ig:DropDownItem Text="CT" Value="CT" /> <ig:DropDownItem Text="DC" Value="DC" /> <ig:DropDownItem Text="DE" Value="DE" /> <ig:DropDownItem Text="FL" Value="FL" /> <ig:DropDownItem Text="GA" Value="GA" /> <ig:DropDownItem Text="HI" Value="HI" /> <ig:DropDownItem Text="IA" Value="IA" /> <ig:DropDownItem Text="ID" Value="ID" /> <ig:DropDownItem Text="IL" Value="IL" /> <ig:DropDownItem Text="IN" Value="IN" /> <ig:DropDownItem Text="KS" Value="KS" /> <ig:DropDownItem Text="KY" Value="KY" /> <ig:DropDownItem Text="LA" Value="LA" /> <ig:DropDownItem Text="MD" Value="MD" /> <ig:DropDownItem Text="ME" Value="ME" /> <ig:DropDownItem Text="MI" Value="MI" /> <ig:DropDownItem Text="MN" Value="MN" /> <ig:DropDownItem Text="MO" Value="MO" /> <ig:DropDownItem Text="MS" Value="MS" /> <ig:DropDownItem Text="MT" Value="MT" /> <ig:DropDownItem Text="NC" Value="NC" /> <ig:DropDownItem Text="ND" Value="ND" /> <ig:DropDownItem Text="NE" Value="NE" /> <ig:DropDownItem Text="NH" Value="NH" /> <ig:DropDownItem Text="NJ" Value="NJ" /> <ig:DropDownItem Text="NM" Value="NM" /> <ig:DropDownItem Text="NV" Value="NV" /> <ig:DropDownItem Text="NY" Value="NY" /> <ig:DropDownItem Text="OH" Value="OH" /> <ig:DropDownItem Text="OK" Value="OK" /> <ig:DropDownItem Text="OR" Value="OR" /> <ig:DropDownItem Text="PA" Value="PA" /> <ig:DropDownItem Text="RI" Value="RI" /> <ig:DropDownItem Text="SC" Value="SC" /> <ig:DropDownItem Text="SD" Value="SD" /> <ig:DropDownItem Text="TN" Value="TN" /> <ig:DropDownItem Text="TX" Value="TX" /> <ig:DropDownItem Text="UT" Value="UT" /> <ig:DropDownItem Text="VA" Value="VA" /> <ig:DropDownItem Text="VT" Value="VT" /> <ig:DropDownItem Text="WA" Value="WA" /> <ig:DropDownItem Text="WI" Value="WI" /> <ig:DropDownItem Text="WV" Value="WV" /> <ig:DropDownItem Text="WY" Value="WY" /> </Items> </ig:WebDropDown> </td> </tr> <tr> <td style="width:30%;padding:5px;text-align:right;"><asp:Label ID="lblZip" runat="server" Text="Zip: *" ForeColor="Red"></asp:Label></td> <td style="padding:5px;"> <ig:WebTextEditor ID="txtZip" runat="server" MaxLength="5" Width="50" CssClass="StyledText" /> </td> </tr> <tr> <td align="center" style="width: 100%; padding:5px;" colspan="2"> <asp:Label ID="lblAddressErrorMsg" runat="server" Font-Bold="True" Width="100%" ForeColor="Red"></asp:Label> <asp:HiddenField ID="SiteID" runat="server" /> </td> </tr> <tr> <td align="center" style="width: 100%; padding:5px;" colspan="2"> <asp:Button ID="btnVerifyAddress" runat="server" Text="Next"/> </td> </tr> </table> </div> </asp:Panel>
Private Sub btnVerifyAddress_Click(sender As Object, e As System.EventArgs) Handles btnVerifyAddress.Click Try lblAddressErrorMsg.Text = "" 'Make sure required fields are present If txtStreetNum.Text = "" Then lblAddressErrorMsg.Text = "Street # is required" End If If txtStreetName.Text = "" Then lblAddressErrorMsg.Text = "Street Name is required" End If If txtStreetType.Text = "" Then lblAddressErrorMsg.Text = "Street Type is required" End If If txtCity.Text = "" Or cboState.CurrentValue = "" Or txtZip.Text = "" Then lblAddressErrorMsg.Text = "City, State, and Zip Code are required" End If
'Check value in list for street dir Dim PassedChecked As Integer = 0 For Each itm As Infragistics.Web.UI.ListControls.DropDownItem In cboStreetDir.Items If UCase(cboStreetDir.CurrentValue) = itm.Value Then cboStreetDir.CurrentValue = itm.Value PassedChecked = 1 End If Next If PassedChecked = 0 Then lblAddressErrorMsg.Text = "Street Direction must be a value in the list" End If
If lblAddressErrorMsg.Text <> "" Then Exit Sub End If
Catch ex As Exception lblAddressErrorMsg.Text = "Error verifying Address information" End Try End Sub
Hi bhouaglound,
Can you send us your complete WebDropDown code definition as well as the button click handler code, so we can investigate where the problem si and help you as fast as possible
Thanks,
In my case autopostback isn't set to true. The postback takes place on a button click event on the page. In the code behind the button click event is where I'm checking for the curent value of the WebDropDown.
Hi bhoaglund,
How are you triggering the postback when you hit the tab key?
I've used your DropDown with AutoPostBack property set to true, and when I hook on SlectionChanged event of the WebDropDown, both the old and new values are in there set correctly. Or maybe I'm not reproducing your case correctly?
Please verify,