Note that there are some explanatory texts on larger screens.

plurals
  1. PONot able to call a javascript function through alert
    primarykey
    data
    text
    <p>I am creating an alert and trying to call a click event through javascript function when "OK" of alert is pressed.It runs pretty well if I create the alert on rpage_Load but When I crate the alert on clicking of a buttton, then on pressing "OK" of alert the required click event is not called.</p> <p>This is how I create the alert </p> <pre><code> protected void Button1_Click(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "Test();", true); } </code></pre> <p>This is the javascript function which calls a click event</p> <pre><code> &lt;script type="text/javascript"&gt; function Test() { alert('There is no Bookmarked Question Available'); document.getElementById('btnReview').click(); } &lt;/script&gt; </code></pre> <p>This is the click event which will be called through Test()</p> <pre><code> protected void btnReview_Click(object sender, EventArgs e) { count = int.Parse((string)ViewState["S.NO"]); dt1 = (DataTable)ViewState["Question"]; if (rbOption.SelectedValue != "") { string strUserOpt = rbOption.SelectedItem.Text; strUserOpt = strUserOpt.Substring(20); dt1.Rows[count - 1][9] = strUserOpt; dt1.Rows[count - 1][10] = rbOption.SelectedValue; } lblReview.Visible = true; tblQues.Visible = false; tblReview.Visible = true; btnBookMark.Text = "Bookmark"; btnBookMark.Font.Bold = false; btnBookMark.BackColor = Color.Empty; lblQuestionNo.Visible = false; lblTopic.Visible = false; lblTestHead.Visible = false; DataTable dt = new DataTable(); dt.Columns.Add("Question"); dt.Columns.Add("Status"); dt.Columns.Add("BookMarked"); DataRow dr1; foreach (DataRow dr in dt1.Rows) { dr1 = dt.NewRow(); dr1[0] = dr[0].ToString() ; if (dr[9].ToString() != "") { dr1[1] = "Attempted"; } else { dr1[1] = "Un-attempted"; } if (dr[11].ToString() != "") { dr1[2] = "Yes"; } else { dr1[2] = "No"; } dt.Rows.Add(dr1); } dt.AcceptChanges(); ClsDataBind.DoGridViewBind(grdReview, dt, _errMsg); btnBookMark.Visible = false; btnNext.Visible = false; btnPrevious.Visible = false; btnReview.Visible = false; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload