The Javascript code block executes before the
DOM[
^](page) is loaded, thats why the page is blank.
Just add
jquery[
^] reference to the page and modify the code as below. it should work.
protected void Button1_Click(object sender, EventArgs e)
{
string alertMessage = "<script language=\"javascript\" type=\"text/javascript\">";
alertMessage += " $(function () { ";
alertMessage += "alert('No quiz avalible');";
alertMessage += "window.location.href=\"";
alertMessage += "View.aspx?Id=" + Request.QueryString["Id"];
alertMessage += "\"; });";
alertMessage += "</script>";
ClientScript.RegisterClientScriptBlock(GetType(), "alertMessage ", alertMessage);
}
jquery reference
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
refer this:
jquery dom ready event[
^]