Onload if we enter value then it shows total fine on clicking add new row the above value get disapper then what ever we are entering it show result in second row... why it disapper?
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback
or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
asteranup
All-Star
30184 Points
4906 Posts
Re: javascript and jquery to show values in lable instead of Textbox
Mar 01, 2012 07:27 AM|LINK
Hi,
You have to change your script like-
<head id="Head1" runat="server"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $(".textSelector").keyup(function () { var row = $(this).closest("tr"); var Rate = parseFloat(row.find("input[type=text][id*=Rate]").val()); if (isNaN(Rate)) Rate = 0; var Quantity = parseFloat(row.find("input[type=text][id*=Quantity]").val()); if (isNaN(Quantity)) Quantity = 0; row.find("span[id*=Amount]").html(Rate * Quantity); var total = calculateTotal(); var taxValue = parseFloat($("span[id*=TaxValue]").html()); if (isNaN(taxValue)) taxValue = 0; $("span[id*=GrandtotalWithTax]").val(total + taxValue); }); }); function calculateTotal() { var total = 0; $("span[id*=Amount]").each(function () { temp = parseFloat($(this).html()); if (isNaN(temp)) temp = 0; total = total + temp; }); $("span[id*=GrandTotalWithoutTax]").html(total); return total; } </script> </head>Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog
roopeshreddy
All-Star
20119 Points
3320 Posts
Re: javascript and jquery to show values in lable instead of Textbox
Mar 01, 2012 08:43 AM|LINK
Hi,
asteranup Code should work fine!
asp:Label tag will be render span tag! So to set the value to span tag, you need to use html() function!
Hope it helps u...
Roopesh Reddy C
Roopesh's Space
Priya_here
Member
709 Points
1854 Posts
Re: javascript and jquery to show values in lable instead of Textbox
Mar 01, 2012 09:23 AM|LINK
hi
Onload if we enter value then it shows total fine on clicking add new row the above value get disapper then what ever we are entering it show result in second row... why it disapper?
me_ritz
Star
9337 Points
1447 Posts
Re: javascript and jquery to show values in lable instead of Textbox
Mar 01, 2012 09:29 AM|LINK
One reason might be, if add new row button is server-side it is causing a postback...and resetting values.
Priya_here
Member
709 Points
1854 Posts
Re: javascript and jquery to show values in lable instead of Textbox
Mar 01, 2012 09:37 AM|LINK
so what to do?
roopeshreddy
All-Star
20119 Points
3320 Posts
Re: javascript and jquery to show values in lable instead of Textbox
Mar 01, 2012 09:43 AM|LINK
Hi,
On Page_Load, remove IsPostBack check and try to bind it!
Hope it helps u...
Roopesh Reddy C
Roopesh's Space
me_ritz
Star
9337 Points
1447 Posts
Re: javascript and jquery to show values in lable instead of Textbox
Mar 01, 2012 09:46 AM|LINK
Either acheive add row functionality client side...or implement calculation logic server-side....
Priya_here
Member
709 Points
1854 Posts
Re: javascript and jquery to show values in lable instead of Textbox
Mar 01, 2012 09:55 AM|LINK
Its says
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
If i removed Is postback from page laod
roopeshreddy
All-Star
20119 Points
3320 Posts
Re: javascript and jquery to show values in lable instead of Textbox
Mar 01, 2012 12:03 PM|LINK
Hi,
Since the Label value is updated from clientscript, then value is not passing from the page to server!
You can examine the request!
I will check it out and let you know!
Roopesh Reddy C
Roopesh's Space
Priya_here
Member
709 Points
1854 Posts
Re: javascript and jquery to show values in lable instead of Textbox
Mar 02, 2012 12:03 PM|LINK
hi
anybody here to help me in this..
Its a long time no reply