Search code examples
asp.netresponse.redirectrequest.querystringonclientclick

How to make a popup in ASP.Net and pass information to it using a query string?


I have all the code I need to response.redirect a page and pass the information I need to the other page. But I don't want it to redirect the page but rather create a popup in the page. I have code for the popup also but I can't manage to pass information to it.

This is the code for the popup and it's not passing any information:

<asp:LinkButton ID="lb_viewstudenttimetable" runat="server" OnClick="lb_viewstudenttimetable_Click" 
     OnClientClick="window.open('Timetable_User.aspx','Timetable','width=640,height=360,scrollbars=yes');">

This is the code for the OnClick button where it passing information to the other page

protected void lb_viewstudenttimetable_Click(object sender, EventArgs e)
{
    GridViewRow row = gv_classlist.SelectedRow;
    Response.Redirect("Timetable_User.aspx?UserID=" + row.Cells[1].Text + "");
    //my attempt of trying to pass the following to the popup        
    //Response.Write("window.open('Timetable_User.aspx?UserID="+row.Cells[1].Text+"','Timetable','width=640,height=360,scrollbars=yes');");
}

So I wanna use OnClientClick to do what that OnClick does.


Solution

  •     GridViewRow row = gv_classlist.SelectedRow;
        lbl_timetableuserid.Text = row.Cells[1].Text;
    
    
        ScriptManager.RegisterStartupScript(this, typeof(string), "New_Window", "window.open('Timetable_User.aspx?UserID=" + row.Cells[1].Text + "', null, 'height=360,width=640,status=yes,toolbar=yes,menubar=yes,location=no' );", true);