public class aa
{
public static void check(string str)
{
bool aa=false;
if (string.IsNullOrEmpty(str) == true)
{
//如何中断所有执行?包括被调用的父类
//这地方如何写啊
//return;不行,
}
}
}
public class bb
{
protected void Button1_Click(object sender, EventArgs e)
{
aa.check(this.text1.text);//目的就是截断下面的操作
...
...
...}
}
{
public static void check(string str)
{
bool aa=false;
if (string.IsNullOrEmpty(str) == true)
{
//如何中断所有执行?包括被调用的父类
//这地方如何写啊
//return;不行,
}
}
}
public class bb
{
protected void Button1_Click(object sender, EventArgs e)
{
aa.check(this.text1.text);//目的就是截断下面的操作
...
...
...}
}
if(aa.check(this.text1.text)==true)
return;aa.check返回bool值确定是否中断
{ if (string.IsNullOrEmpty(stringstr) == true)
{
rayelert.ShowLocation(messge + "不能为空!", "javascript:history.back()", 1);
return;
// HttpContext.Current.Response.End();
}
else
{
if (stringstr.Length > length)
{
rayelert.ShowLocation(messge + "输入过多字符!", "javascript:history.back()", 1);
return;
}
}
}
页面事件
protected void Button1_Click(object sender, EventArgs e)
{
ray_stringedit.input_check_inputty(9, Request.Form["inputjia1"], "最低价格", 1);
return不行,我把代码都贴出来了,你看看。它还是能继续往下执行
{}//这个方法应该返回一个布尔类型
//应该改成下面的:public static bool check(string str)
{
if (string.IsNullOrEmpty(str))
{
return false;
}
return true;
}
//然后在bb类就可以如下:
if(!(aa.check(this.text1.text)))
{
return;
}
//目的就是截断下面的操作
{
if (input_check_two(2, "aaaa", "bbbb"))
{
Console.WriteLine("返回为true继续执行操作");
}
else
{
Console.WriteLine("提示错误信息");
}
} public static bool input_check_two(int length, string stringstr, string messge)
{
bool bl = true;
if (string.IsNullOrEmpty(stringstr) == true)
{
bl = false;
rayelert.ShowLocation(messge + "不能为空!", "javascript:history.back()", 1);
// HttpContext.Current.Response.End();
}
else
{
if (stringstr.Length > length)
{
bl = false;
rayelert.ShowLocation(messge + "输入过多字符!", "javascript:history.back()", 1);
}
}
return bl;
}