检查URL参数是否合法

 

 string combinationID = Request.QueryString["CombinationID"];
        string buyingPriceListID = Request.QueryString["PriceListID"];
        if (combinationID != null && CommonFunction.IsInt(combinationID) && combinationID.Length < int.MaxValue.ToString().Length)
        {
            m_CombinationID = int.Parse(combinationID.ToString());
        }
        if (buyingPriceListID != null && CommonFunction.IsInt(buyingPriceListID) && buyingPriceListID.Length < int.MaxValue.ToString().Length)
        {
            m_BuyingPriceListID = int.Parse(buyingPriceListID.ToString());
        }

public static bool IsInt(string input)
        
{
            
return Regex.IsMatch(input, @"^\d+$");
        }


string script = "<script type='text/javascript'>alert('{0}');window.location.href='BuyingPriceList.aspx';</script>";
        
if (this.m_CombinationID == 0 || !entityCombination.ObjectExist)
        
{
            script 
= string.Format(script, this.getMessage("M10022"));
            Response.Write(script);
            Response.End();
        }

        
if (this.m_BuyingPriceListID == 0 || !entityBPList.ObjectExist)
        
{
            script 
= string.Format(script, this.getMessage("M10023"));
            Response.Write(script);
            Response.End();
        }
      

posted on   Sammy  阅读(515)  评论(0编辑  收藏  举报

< 2007年4月 >
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 1 2 3 4 5
6 7 8 9 10 11 12

导航

统计

点击右上角即可分享
微信分享提示