javascript - Microsoft JScript runtime error: 'DeleteRowFromCart' is undefined -
i have been lately facing "function undefined error" , little bit frustrating.
i have web application trying build java-script page dynamically using stringbuilder
class in code-behind. in code-behind i'm associating onclick
event anchor tag.
the click event never seems fire .
i error saying:
unhandled exception @ line 794, column 1 in script block 0x800a1391 - microsoft jscript runtime error: 'deleterowfromcart' undefined
javascript code :
script includes
<link href="styles/jquery.mobile-1.2.0.min.css" rel="stylesheet" type="text/css" /> <script src="scripts/jquery.min.js" type="text/javascript"></script> <script src="scripts/jquery.mobile-1.2.0.min.js" type="text/javascript" > </script> <script type="text/javascript"> function deleterowfromcart(tableid) { // function logic } </script>
code behind : : build page dynamically
stringbuilder cartstring = new stringbuilder(string.empty); cartstring.append(@"<tr><td></td><td align='right'> <a data-role='button' data-mini='true' data-icon='delete' data-theme='a' onclick='deleterowfromcart("+ product.tableid+");'>delete</a></td></tr>"); cartstring.append("</table></li>"); cartpanel.controls.add(new literalcontrol(cartstring.tostring()));
the cartpanel here asp panel
<asp:panel runat="server" id="cartpanel" />
i don't know perchance wrong here . help appreciated.
single quote problem seek replacing next -
onclick='deleterowfromcart("+ product.tableid+");' onclick=deleterowfromcart('"+ product.tableid+'");
update - add together javascript before function.
string tableid="table01"; stringbuilder cartstring = new stringbuilder(string.empty); cartstring.append(@"<tr><td></td><td align='right'> <a data-role='button' data-mini='true' data-icon='delete' data-theme='a' onclick=javascript:deleterowfromcart('" + tableid + "');>delete</a></td></tr>"); cartstring.append("</table></li>"); cartpanel.controls.add(new literalcontrol(cartstring.tostring()));
javascript asp.net
No comments:
Post a Comment