Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
In the following code I have a button and a label inside a table within updatepanel.
During runtime on click of that button, I increment variable v_mycart by one and assign it to LblMyCart. But, the display for LblMyCart is not showing the latest value in LblMyCart.text. How to make the latest value to display immediately once the label control's value changes?
XML
<asp:UpdatePanel ID="hh" runat="server" >
    <ContentTemplate>
    <div>
    <table class="" style=" margin-left:1145px; height:43px; margin-top:-90px;  " width="300">
    <tr>
    <td>
    <asp:Button id="BtnMyCart" runat="server"  OnClick="BtnMyCart_Click" BorderStyle="None" Text="My Cart" ForeColor="#666666"
    style=" margin-left:-8px; height:36px; cursor:pointer; margin-top:51px; width:50px; text-align:center;  background-color:Transparent; font-weight:normal" />
    </td>
    <td>
    <asp:Label ID="LblMyCart" runat="server" ForeColor="#333333" Text="0" BackColor="White"  style="  font-size:medium; font-weight:normal; width:45px; margin-top:16px; position:absolute;  text-align:left; margin-left:-245px; "></asp:Label>
    </td>
    </tr>
    </table>
    </div>
 </ContentTemplate>
 </asp:UpdatePanel>


C#
v_MyCart = v_MyCart + 1;
              Session["mycart"] = v_MyCart;
              LblMyCart.Text = Convert.ToString("(" + v_MyCart + ")");
              LblMyCart.Visible = true;
Posted
Comments
Maciej Los 13-Apr-14 9:39am    
S.Rajendran from Coimbatore 13-Apr-14 9:51am    
No, I have not used it.
S.Rajendran from Coimbatore 13-Apr-14 9:56am    
Even I keep the Label control outside Update Panel it is not working
Maciej Los 13-Apr-14 12:15pm    
Do not move label outside updatepanel. Just call Update method and find out what happens.

1 solution

Hi Rajendran,
I think you are using update panel.
Just remove the update panel and try it once.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900