我在ASP.Net和C#中保存一個表單。除保存後的消息不顯示外,每件事情都可以正常工作。它在兩地之間迷路了,我無法弄清楚爲什麼?爲什麼這行不執行?
protected void btnSave_Click(object sender, EventArgs e)
{
int fisherId;
try
{
if (ValidateControls())
{
_traceLog.AppendLine("Fisheries Registration Form saving : btnSave_Click() ");
FillDemographicsObjects();
if(_manager.CreateFisherDemographics(_demographics, _address, "Test User",out fisherId))
{
/*ShowMessage(IntertribalFishriesResource.msgSaveSuccess);*/
if (_shared.SendMailToFisher(fisherId))
{
_traceLog.AppendLine("Fisheries Registration Form ending : btnSave_Click() ");
Response.Redirect("~/Fisher/FisherRegistration.aspx?Id=" + fisherId, false);
}
}
}
}
catch (Exception ex)
{
_userException.CreateExceptionLog(ex);
}
finally
{
_userException.CreateTraceLog(_traceLog.ToString());
}
}
以灰色文字顯示的信息不會執行。 ShowMessage給出如下:
protected bool ShowMessage(string message)
{
if (message.Length > 0)
{
hidErrMsg.Value = message;
ScriptManager.RegisterStartupScript(upFisherRegistration, this.GetType(), "myScript", "ShowMessage();",true);
return false;
}
return true;
}
我想實現的是,成功的保存操作後,我想要顯示消息和重定向頁面。就這樣。
電子郵件是否被髮送? – 2011-01-27 17:21:16
除警告消息外,一切正常。即使我只在腳本管理器下提醒,它不會工作。 – 2011-01-27 17:22:14