首先设计一个容错提示的窗口图像为如下:
关键html文本如下:
“原因:<%=content[int32.parse(request.querystring["ms"])]%>”
然后在代码编辑窗口中添加如下不分:
public class webform1 : system.web.ui.page
{
public string[] content;
private void page_load(object sender, system.eventargs e)
{
content=new string[10];
content[1]=".提示1.";
content[2]="提示2";
… …
}
===========================================
在容错的网页中这样调用:
[/*以下是一个示例!*/]
public void check()
{//检测用户输入的合法性;
//检测[订单号][类型]是否为空白;
if (lordername.innertext.trim() == "" || lordercategory.innertext.trim() == "")
{
response.redirect(@"..\exceptions.aspx?ms=11");
}
//判断用户输入的数量是否正确;
try
{
int i = convert.toint16(tbquantity.text);
if (i ==0)
{
response.redirect(@"..\exceptions.aspx?ms=12");
}
}
catch
{
response.redirect(@"..\exceptions.aspx?ms=12");
}
//判断日期是否正确;
try
{
convert.todatetime(tbterm.text);
}
catch
{
response.redirect(@"..\exceptions.aspx?ms=9");
}
//判断交货期必须大于开单日期;
if (convert.todatetime(tbterm.text) < convert.todatetime(request.cookies["order"].values["date"]))
{
response.redirect(@"..\exceptions.aspx?ms=14");
}
//判断当前的型号在当前订单中是否已经存在;
dataclass dc = new dataclass();
if (dc.checkmodel(lordername.innertext,lbmodel.selectedvalue.tostring()))
{
response.redirect(@"..\exceptions.aspx?ms=13");
}
//当订单类型为:“s-p”时,检测不能超出上限;
if (lordercategory.innertext=="s-p")
{
if (convert.toint32(tbquantity.text) > convert.toint32(lbupper.innertext))
{
response.redirect(@"..\exceptions.aspx?ms=18");
}
}
}
==========================================
其中exceptions.aspx就是我们刚才定义的那个容错窗口了!