On Feb 12, 5:48 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.comwrote:
Yes, the problem is that you are trying to use Response.Redirect (which is
server-side .NET code) in client-side script, which won't work. Use
location.href=newurl;
instead.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Dan" wrote:
Hi,
i try to redirect to another aspx page with jscript. I use "OnClientClick"
but nothing happens.
I tried two ways.
What am i doing wrong?
Thanks
Dan
....
<form id="form1" runat="server">
<asp:Button ID="ContinueButton" runat="server" OnClientClick="return
profiel()" />
</form>
....
<script language="javascript" type="text/javascript">
function profiel()
{
//window.location.href="page2.aspx"
Response.Redirect("page2.aspx")
}
</script>- Hide quoted text -
I'd recommend to move js above and add "return false"
Example:
<script language="javascript" type="text/javascript">
function profiel()
{
window.location.href="page2.aspx";
return false;
}
</script>
<asp:Button ID="ContinueButton" runat="server" OnClientClick="return
profiel();" />