user1568844
user1568844

Reputation: 1

Dropdown not Updating lbl in Updatepanel

Situation: Checkbox inside a updatepanel multiline textbox inside a different updatepanel. if the user checks the checkbox, the multiline text box gets a name... this works fine.

HTML:

<asp:UpdatePanel ID="upTraveling" runat="server" 
    UpdateMode="Conditional"   ChildrenAsTriggers="False">   
    <ContentTemplate>                        
       <asp:CheckBox ID="cbRUTraveler" runat="server" Text="I am a Traveler" AutoPostBack="True" 
     oncheckedchanged="cbRUTraveler_CheckedChanged1" />
    </ContentTemplate>
</asp:UpdatePanel>
<td>
  <asp:UpdatePanel ID="upTravelers" runat="server" ondatabinding="cbRUTraveler_CheckedChanged1"
     UpdateMode="Conditional">
   <ContentTemplate>
    <asp:TextBox ID="tbTravelers" 
      Class="textwidth"   runat="server" TextMode="MultiLine" 
      placeholder="FName LName, FName  LName" required="required">
   </asp:TextBox>
  </ContentTemplate>
  <Triggers>
      <asp:AsyncPostBackTrigger 
       ControlID="cbRUTraveler" EventName="CheckedChanged" />
  </Triggers>
 </asp:UpdatePanel>

C#:

protected void cbRUTraveler_CheckedChanged1(object sender, EventArgs e)
{
   tbTravelers.Text = 
   RequesterBPL.RequesterTraveling(cbRUTraveler.Checked, tbTravelers.Text);
   going = cbRUTraveler.Checked;
}

I also have 2 other updatepanels on the same page... a dropdown list in one updatepanel and a label in another updatepanel. When a user selects a value in the dropdown list... it's suppose to trigger a name placement in the label.

HTML:

 <td>
     <asp:UpdatePanel ID="upManager" runat="server" 
        ondatabinding="ddlTeam_SelectedIndexChanged" 
         UpdateMode="Conditional">
          <Triggers>
              <asp:AsyncPostBackTrigger ControlID="ddlTeam" 
                EventName="SelectedIndexChanged" />                                         
          </Triggers>
          <ContentTemplate>
                 <asp:Label ID="lblManager" runat="server" >  </asp:Label>                                    
          </ContentTemplate>                                  
    </asp:UpdatePanel>                            
 </td>

C#:

 protected void ddlTeam_SelectedIndexChanged(object sender, EventArgs e)
 {
     //upManager.Update(); 
     lblManager.Text = 
     ManagerBPL.ReturnManagerName(ddlTeam.SelectedIndex);
 }       

However, when a user makes a selection in the dropdown, nothing happens. until the user checks the checkbox which has nothing to do with the label and the dropdown. Once the user checks (or unchecks) the checkbox... the label gets populated with the selection from the dropdown.

All controls are in a table for structure. I have the scriptmanager in place.

From what I've been reading on the net this maybe a bug... If not a bug does anyone see where I may be going wrong...?

Thanks

Upvotes: 0

Views: 486

Answers (1)

Greg
Greg

Reputation: 11480

Honestly you could do this all Client-Side. A simple example:

$(function () {
     $('#<%= drpContent.ClientID %>').blur(function () {
          var content = $('#<%= drpContent.ClientID %> option:selected').val();
          $('#lblContent').text(content);
     }     
});

I've provided the initial example with the value declared. The second example is with a text representation.

$(function () {
     $('#<%= drpContent.ClientID %>').blur(function () {
          var content = $('#<%= drpContent.ClientID %> option:selected').text();
          $('#lblContent').text(content);
     }     
});

An example with a Fiddle. The example though is simple, is far easier then dealing with an Update Panel. That particular control can be a nightmare to deal with, it can be quite painful. Though you asked about the server issue, this option is more viable and more common.

Update Panel (Drawback):

  • Creates pandomonium between Client / Server Side Events.
  • Stores your entire page in memory, then recreates (Performance Heavy)
  • Often breaks Page-State quickly in the Asp.Net Page Life Cycle.

Hopefully this helps.

Upvotes: 1

Related Questions