Thursday, March 6, 2014

Response.Redirect () in JavaScript


Sometimes we need to redirect our page on through JavaScript function and also in code behind using JavaScript . Here the solution

   1.  Redirection Without Parameter

 var url='<%# ResolveUrl("~/Modules/WorkOrder/WorkOrderAddTask.aspx") %>';
 windows.location.href=url;;

   2.  Redirection With Parameter

 var url='<%# ResolveUrl("~/Modules/WorkOrder/WorkOrderAddTask.aspx?WID=' + Wid + '&TID='+Tid+ '") %>';

 windows.location.href=url;

  3.  Redirection from CodeBehind

  ScriptManager.RegisterStartupScript(this, this.GetType(), "scriptid", "   window.top.location='" + Page.ResolveUrl("~/FrmLogin.aspx") + "';", true);

    3.  Redirection from CodeBehind With Parameter

  ScriptManager.RegisterStartupScript(this, this.GetType(), "scriptid", "   window.top.location='" + Page.ResolveUrl("~/FrmLogin.aspx?ID="+1+"&Name="+ variable ) + "';", true); 

I hope all will work must.

No comments:

Post a Comment