嵌入式代码块在.net中使用Javascript时出错 [英] Error with Embedded code blocks using Javascript in .net

查看:113
本文介绍了嵌入式代码块在.net中使用Javascript时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我这样给出时,我得到一个错误未终止字符串常量



I get an error Unterminated String Constant when I give like this

<input type="button" name="cancel" value="Close" onClick="javascript:top.location.href = '../admin/page.aspx?curTab=<%=curTab%>';">



我得到了minated string对于以下代码行,'&'的常量和语法错误


And I get unterminated string Constant and syntax error for this at the '&' for the following line of code

<input type="button" name="cancel" value="Close" onClick="javascript:top.location.href = 'plan.aspx?res=<%=Request("res")%>&Count=<%=Request("count")%>';">



可以请问有谁发生这种情况?我想这是因为嵌入式代码块。请帮帮我



提前谢谢!


Can anybody please tell me whys this happens?I suppose this is because of the embedded code block. Please help me

Thanks in advance !

推荐答案

不太确定随便,但你可以消除这个问题通过在代码后面添加你的onlcick处理程序 - 无论如何,它更整洁......



在你的页面上添加



Not really sure offhand, but you can probably eliminate this issue by adding your onlcick handler in code behind instead - anyway, it's much neater...

On your page add

<asp:button runat="server" id="cancel" text="Close" xmlns:asp="#unknown" />





并在你的代码中添加





and in your code behind add

cancel.attributes.Add("onclick", "top.location.href = '../admin/page.aspx?curTab=" & curTab & "'; return false;")





NB



NB the

return false;



这将停止服务器控制从点击后回发(假设这就是你想要的。)



在你的第二个案例中你有:




this will stop the server control from posting back when clicked (asssuming that's what you want.)

In your second case you'd have:

cancel.attributes.Add("onclick", "top.location.href = 'plan.aspx?res=" & Request("res") & "&Count=" & Request("count") & "'; return false;")


这篇关于嵌入式代码块在.net中使用Javascript时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆