Reputation: 5569
I am trying to redirect to current page using javascript from server side using this code ..
ScriptManager.RegisterStartupScript(this, this.GetType(), "pop", "<script>alert('Record saved with claim number " + lastid + ".');var currentPageUrl =document.location.toString().toLowerCase();window.location.assign('currentPageUrl')</script>", false);
But it does not work. How can I make it work?
Upvotes: 0
Views: 121
Reputation: 2788
Try This.
Page.ClientScript.RegisterStartupScript(this.GetType(), "success_msg_1", "<script language='javascript' type='text/javascript'>alert('Record saved with claim number " + lastid + ".');location.replace('pageurl');</script>");
Upvotes: 0
Reputation: 12961
you should just remove the quotes, because currentPageUrl
is a JavaScript variable, but you pass it just as a string. change:
window.location.assign('currentPageUrl')
to
window.location.assign(currentPageUrl)
Upvotes: 1