0
Answer

location.Replace

Photo of syed maricar

syed maricar

19y
2.3k
1
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.

Answers (0)