0
Reply

location.Replace

syed maricar

syed maricar

Dec 28 2005 12:22 AM
1.7k
Hi,
    Location.Replace("URL") is not working for server controls like <asp:button>.

    Here is my code.

protected void _btn2_Click(object sender, System.EventArgs e)
{
string URL="http://forums.csharpcorner.com/AddPost.aspx?TSource=AddPost";
string func="";
func += "<script language='javascript'>";
func += "window.location.replace('" + URL+ "','X');";
func += "</script>";
if(!IsClientScriptBlockRegistered("window.location.replace"))
{
Page.RegisterClientScriptBlock("window.location.replace", func);
}
}

It is redirecting to the new location, but the "Back" button in the browser is getting enabled.
I dont want this button to be enabled.

But the same location.replace("URL") is working for HTML buttons.

How we can make it possible in Server controls??
Any idea?

Regards,
Syed.