I'm using the method below as a button-click event on an ASP.NET 4.0 page. The first alert box (ClientScript.RegisterStartupScript(...)) works fine, the second I haven't tested yet; but the third doesn't produce an alert - and it doesn't produce an error either. Can anyone suggest what I'm missing here? I'm doing the same thing in all 3 attempts to display the alert box - using a string variable as the text to display.
From CodeBehind.aspx.cs:
protected void btnUpdateClients_Click(object sender, EventArgs e)
{
string[] strRecs;
string strResponse = util.ValidateInput(this.FileUploadGuids.FileName, "none", this.txtBuild.Text, this.rbMTBFEnvs.Text);
Stream myStream = FileUploadGuids.FileContent;
int contentLen = (int) FileUploadGuids.PostedFile.ContentLength;
if (strResponse.Length > 0)
{
ClientScript.RegisterStartupScript(this.GetType(), "MyKey", "alert('" + strResponse + "');", true);
return;
}
strResponse = "";
strRecs = util.BuildStringArray(myStream, contentLen);
string[] theCreds = util.getCreds(CredsDict, this.rbMTBFEnvs.Text).Split(',');
try
{
PrincipalManagement pmClass = new PrincipalManagement(theCreds[0], theCreds[2], theCreds[3], theCreds[1]);
strResponse = util.ClientUpdates(pmClass, strRecs, this.txtBuild.Text);
}
catch (Exception ex)
{
ClientScript.RegisterStartupScript(this.GetType(), "MyKey", "alert('" + ex.Message + "');", true);
}
ClientScript.RegisterStartupScript(this.GetType(), "MyKey", "alert('" + strResponse + "');", true);
}