62,073
社区成员
发帖
与我相关
我的任务
分享
protected void Page_Load(object sender, EventArgs e)
{
……
if (IsPostBack)
{
Control c = null;
if (Request.Form["__EVENTTARGET"].Length != 0)
{
c = Page.FindControl(Request.Form["__EVENTTARGET"]);
}
else
{
foreach (string v in Request.Form)
{
c = Page.FindControl(v);
if (c != null)
{
break;
}
}
}
if (c != null)
{
bool CauseValidation = false;
if (c is Button)
{
CauseValidation = ((Button)c).CausesValidation;
}
else if (c is LinkButton)
{
CauseValidation = ((LinkButton)c).CausesValidation;
}
if (CauseValidation)
{
if (Text.Length == 0)
{
throw new CustomException("请选择栏位(" + new SDTextBox().GetTagName(TagName) + ")");
}
}
}
}
……
}
/// <summary>
/// 异步回发错误处理
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ScriptManager1_OnAsyncPostBackError(object sender, System.Web.UI.AsyncPostBackErrorEventArgs e)
{
#if DEBUG
this.ScriptManager1.AsyncPostBackErrorMessage = e.Exception.Message + e.Exception.StackTrace;
#else
this.ScriptManager1.AsyncPostBackErrorMessage = e.Exception.Message;
#endif
string errMessage = e.Exception.Message;
errMessage = errMessage.Replace("\r\n", "-");
errMessage = errMessage.Replace("\\", "/");
ScriptManager.RegisterStartupScript(Page, Page.GetType(), new Random().Next().ToString(), "setTimeout('CustomAlert(\"" + errMessage + "\");',0);", true);
return;
}