Click here to Skip to main content
15,917,565 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all

Problem is I have hidden variable and stored a value to hidden variable through javascript
while retrieving hidden varaible from code behind it is retrieved as empty value

javascript code is
JavaScript
function CalculateTotalAmountWithLoadingCharge() {
var loadingValue = parseFloat(document.getElementById('<%= txtLoadingcharge.ClientID %>').value)
if (loadingValue >= 0) {
document.getElementById('<%= hdnLoadingCharge.ClientID %>').value = loadingValue
document.getElementById('<%= hdnLoadingChargeTemp.ClientID %>').value = "valuechanged";

}

HTML
<asp:UpdatePanel ID="upHiddenField" runat="server" >
<ContentTemplate>
<asp:HiddenField ID="hdnQuantity" runat="server" />
<asp:HiddenField ID="hdnLoadingCharge" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>

<asp:UpdatePanel ID="upFreightType" runat="server"  UpdateMode="Conditional" >
        <ContentTemplate>
        
                <asp:TextBox ID="txtQuantity"  runat="server" CssClass="textBox" Text="1" onchange="onchangeQuantity();" Width="40px" />
             <
                <asp:TextBox ID="txtBasicAmount" runat="server" onchange="BasicAmountChange()" Text="0"  CssClass="textBox" Width="160px" />
            </div>
      
        
        <%--</td>
        </tr>
             <tr align="left">
           <td  style="width:100%;">--%>
                <asp:Label ID="lblLoadingCharge" runat="server" Text="Loading Charge:" CssClass="label" />
                 <asp:TextBox ID="txtLoadingcharge" runat="server" CssClass="textBox" Text="0" onchange="CalculateTotalAmountWithLoadingCharge()" Width="160px" />
                 </div>
             
                 <asp:Label ID="lblTotalAmount" runat="server" Text="Total Amount:" CssClass="label" />
                <asp:TextBox ID="txtTotalAmount"  runat="server" Text="0" CssClass="textBox"  Width="160px" />
             
      </ContentTemplate>
        <Triggers>
        <asp:AsyncPostBackTrigger ControlID="ddlFreightType" EventName="SelectedIndexChanged" />
        </Triggers>
        </asp:UpdatePanel>
        </td>
        </tr>
 


<asp:Button ID="btnSave" runat="server" Text="Book" CssClass="button" Width="160px" OnClientClick="CalculateTotalAmountWithLoadingCharge();" />

in code behind

Dim loadingcharge As Integer=hdnLoadingCharge.Value

I have update panel to get value to retrieve the value on dropdown selected index changed that works fine after retrieving the value i process and store it in hidden variable while trying
to access it in my code behind the value of hidden variable is empty string (i.e) "".

How can i retrieve the hidden variable value from code behind


Thanks in advance . what have i done wrong
Posted
Updated 23-Jun-13 10:11am
v4
Comments
Thanks7872 23-Jun-13 13:50pm    
Rremove unnecessary code. No one would like to go through this lengthy codeblock.
RahulRana723 24-Jun-13 1:08am    
Try to use only one update panel instead of two..
vaibhav10Dec1987 27-Jun-13 3:57am    
Try to use "AsyncPostBackTrigger" for Control Id "txtLoadingcharge".

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