我有以下代码,但没有显示警告框.
try
{
do something..
}
catch(Exception ex)
{
Response.Write("<script>alert('"+ex+"')</script>");
}
Run Code Online (Sandbox Code Playgroud)
如果我使用此代码,则会出现警告框.
try
{
do some thing
}
catch (Exception ex)
{
Response.Write("<script>alert(\"an error occur\")</script>");
}
Run Code Online (Sandbox Code Playgroud)
如何在警告框中显示异常变量?
我对TextBox控件添加到窗体的Controls属性的顺序有一个特殊的问题.
目前,我有这个功能:
public static bool IsValidate(System.Windows.Forms.Form Frm)
{
foreach (Control ctrl in Frm.Controls)
if (ctrl is TextBox)
// if (((TextBox)ctrl).AccessibleDescription == "Valid" && ((TextBox)ctrl).Text == string.Empty)
if (((TextBox)ctrl).AccessibleDescription == "Valid" && ((TextBox)ctrl).Text.Trim()== "")
{
MessageBox.Show(((TextBox)ctrl).AccessibleName + " Can't be Blank", Program.companyName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
((TextBox)ctrl).Focus();
return false;
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
但它正在随机迭代文本框,即使我已经设置了它们的标签索引.
所以我再次开发相同的表单并按顺序创建文本框.但是,当我将表单传递给此函数时,它会随机迭代文本框.
我想知道控件的任何属性是否允许我管理它们的流程.