Reputation: 5150
I am inside an event and inside this event I want to have a javascript alert display a message to a user. But I cannot seem to get this to work.
protected void dgvStaff_Deleting(object sender, Infragistics.Web.UI.GridControls.RowDeletingEventArgs e)
{
// Code stub
object test = e.Row.Items[0].Text;
//ScriptManager.RegisterStartupScript(this, this.GetType(), "alertbox", "ShowPopup('Select a row to rate');", true);
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertbox", "ShowPopup('Select a row to rate');", true);
if (objGatewayFunctions.CheckStaffAssignment(e.Row.Items[0].Text.ToString(), ConfigurationManager.AppSettings.Get("Connection").ToString()) == true)
{
}
}
Any idea what I am doing wrong here?
Upvotes: 1
Views: 487
Reputation: 1838
Use this
Response.Write("<script type='text/javascript'>alert('Hello World');</script>");
Upvotes: 0
Reputation: 16698
You have to wait for the completion of Server execution, then you may able to see the Client side execution in action.
Upvotes: 0
Reputation: 100527
You can't do that - C# and JavaScript run on different computers and you can't jump between them in the middle of a function.
Normally you delay errors/warnings till page is rendered. To improve user experience also try to do error checking before posting back to server (in addition to server side checks).
Upvotes: 6