answer:
if(Page.IsValid){
Response.Redirect("abc.aspx");
}
Otherwise, the page do not have chance to be validated.
if(Page.IsValid){
Response.Redirect("abc.aspx");
}
If you love linq and want to get it runs in .NET Framework 2.0 environment, don't worry just copy those files below into your application bin and do some settings in the web.config and it will works.
System.Core.dll
System.Data.DataSetExtensions.dll
System.Data.Linq.dll
System.Web.dll
System.Web.Extensions.dll
System.Xml.Linq.dll
Where to find all these files?
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;
using System.Text;
namespace WebApplication1
{
public class ItemFeq
{
private string _PhotoName;
public string PhotoName
{
get { return _PhotoName; }
set { _PhotoName = value; }
}
private int _Count;
public int Count
{
get { return _Count; }
set { _Count = value; }
}
private int _Size;
public int Size
{
get { return _Size; }
set { _Size = value; }
}
public ItemFeq(string photoname, int count, int size)
{
_PhotoName = photoname;
_Count = count;
_Size = size;
}
}
public class ItemTag
{
private int _ItemID;
public int PhotoID
{
get { return _ItemID; }
set { _ItemID = value; }
}
private string _Tag;
public string Tag
{
get { return _Tag; }
set { _Tag = value; }
}
public ItemTag(int itemid, string tag)
{
_Tag = tag;
_ItemID = itemid;
}
}
public class ItemTagComparer : IComparer<ItemTag>
{
public int Compare(ItemTag x, ItemTag y)
{
if (x.Tag == y.Tag) { return 0; } else { return x.Tag.CompareTo(y.Tag); }
}
}
public class ItemFeqByCountComparer : IComparer<ItemFeq>
{
public int Compare(ItemFeq x, ItemFeq y)
{
if (x.Count == y.Count)
{ return 0; }
else
{ return x.Count.CompareTo(y.Count); }
}
}
public partial class _Default : System.Web.UI.Page
{
public string CreateTagCloud(List<ItemTag> tags, int baseSize)
{
tags.Sort(new ItemTagComparer());
List<ItemFeq> photofeqlist = new List<ItemFeq>();
foreach (ItemTag ptag in tags)
{
if (photofeqlist.Exists(delegate(ItemFeq pf) { return pf.PhotoName == ptag.Tag; }))
{
photofeqlist.Find(delegate(ItemFeq pq) { return pq.PhotoName == ptag.Tag; }).Count += 1;
photofeqlist.Find(delegate(ItemFeq pq) { return pq.PhotoName == ptag.Tag; }).Size += 1;
}
else
{
photofeqlist.Add(new ItemFeq(ptag.Tag, 1, baseSize));
}
}
photofeqlist.Sort(new ItemFeqByCountComparer());
photofeqlist.Reverse();
StringBuilder sb = new StringBuilder();
int sum = 0;
foreach (ItemFeq pf in photofeqlist)
{
sum += pf.Count;
}
foreach (ItemFeq pf in photofeqlist)
{
sb.Append("<span style='font-size:" + (pf.Size / (sum / photofeqlist.Count)) * baseSize + "pt'>" + pf.PhotoName + " </span>");
}
return sb.ToString();
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
List<ItemTag> phototags = new List<ItemTag>();
phototags.Add(new ItemTag(121, "palad1"));
phototags.Add(new ItemTag(122, "palad1"));
phototags.Add(new ItemTag(123, "palad1"));
phototags.Add(new ItemTag(124, "palad1"));
phototags.Add(new ItemTag(125, "palad1"));
phototags.Add(new ItemTag(126, "palad2"));
phototags.Add(new ItemTag(122, "palad2"));
phototags.Add(new ItemTag(122, "palad2"));
phototags.Add(new ItemTag(121, "palad2"));
phototags.Add(new ItemTag(122, "palad2"));
phototags.Add(new ItemTag(121, "palad2"));
phototags.Add(new ItemTag(126, "palad2"));
phototags.Add(new ItemTag(121, "palad2"));
phototags.Add(new ItemTag(122, "palad2"));
phototags.Add(new ItemTag(121, "palad2"));
phototags.Add(new ItemTag(122, "palad3"));
phototags.Add(new ItemTag(123, "palad3"));
phototags.Add(new ItemTag(124, "palad3"));
phototags.Add(new ItemTag(125, "palad4"));
phototags.Add(new ItemTag(126, "palad4"));
phototags.Add(new ItemTag(121, "palad1"));
phototags.Add(new ItemTag(122, "palad1"));
phototags.Add(new ItemTag(121, "palad1"));
phototags.Add(new ItemTag(122, "palad1"));
phototags.Add(new ItemTag(121, "palad1"));
phototags.Add(new ItemTag(122, "palad1"));
phototags.Add(new ItemTag(121, "palad1"));
phototags.Add(new ItemTag(122, "palad1"));
phototags.Add(new ItemTag(121, "palad1"));
phototags.Add(new ItemTag(122, "palad1"));
phototags.Add(new ItemTag(121, "palad1"));
phototags.Add(new ItemTag(122, "palad1"));
Literal1.Text = CreateTagCloud(phototags, 12);
}
}
}
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
namespace WebApplication1
{
public class PhotoFeq
{
private string _PhotoName;
public string PhotoName
{
get { return _PhotoName; }
set { _PhotoName = value; }
}
private int _Count;
public int Count
{
get { return _Count; }
set { _Count = value; }
}
public PhotoFeq(string photoname, int count)
{
_PhotoName = photoname;
_Count = count;
}
}
public class PhotoTag
{
private int _PhotoID;
public int PhotoID
{
get { return _PhotoID; }
set { _PhotoID = value; }
}
private string _Tag;
public string Tag
{
get { return _Tag; }
set { _Tag = value; }
}
public PhotoTag(int photoid, string tag)
{
_Tag = tag;
_PhotoID = photoid;
}
}
public class PhotoTagEqualityComparer : IEqualityComparer<PhotoTag>
{
public bool Equals(PhotoTag x, PhotoTag y)
{
if (x.Tag == y.Tag )
{
return true;
}
else
{
return false;
}
}
public int GetHashCode(PhotoTag obj)
{
return base.GetHashCode();
}
}
public class PhotoTagComparer : IComparer<PhotoTag>
{
public int Compare(PhotoTag x, PhotoTag y)
{
if (x.Tag == y.Tag) { return 0; } else { return x.Tag.CompareTo(y.Tag); }
}
}
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
//output
//kiki 1
//gigi 2
//jojo 3
//sasa 3
//lala 6
//nini 6
List<PhotoTag> phototags = new List<PhotoTag>();
phototags.Add(new PhotoTag(121, "lala"));
phototags.Add(new PhotoTag(122, "lala"));
phototags.Add(new PhotoTag(123, "lala"));
phototags.Add(new PhotoTag(124, "lala"));
phototags.Add(new PhotoTag(125, "lala"));
phototags.Add(new PhotoTag(126, "lala"));
phototags.Add(new PhotoTag(127, "jojo"));
phototags.Add(new PhotoTag(128, "jojo"));
phototags.Add(new PhotoTag(129, "jojo"));
phototags.Add(new PhotoTag(120, "gigi"));
phototags.Add(new PhotoTag(1201, "gigi"));
phototags.Add(new PhotoTag(1202, "kiki"));
phototags.Add(new PhotoTag(1203, "sasa"));
phototags.Add(new PhotoTag(1204, "sasa"));
phototags.Add(new PhotoTag(1205, "sasa"));
phototags.Add(new PhotoTag(1206, "nini"));
phototags.Add(new PhotoTag(1207, "nini"));
phototags.Add(new PhotoTag(1208, "nini"));
phototags.Add(new PhotoTag(1209, "nini"));
phototags.Add(new PhotoTag(1211, "nini"));
phototags.Add(new PhotoTag(1212, "nini"));
//3.5 method
var feqTags = from n in phototags
group n by n.Tag into g
orderby g.Count()
select new { PhotoName = g.Key , Count = g.Count() };
foreach (var g in feqTags)
{
Response.Write(g.PhotoName + " " + g.Count + "<br/>");
}
//2.0 method
phototags.Sort(new PhotoTagComparer());
List<PhotoFeq> photofeqlist = new List<PhotoFeq>();
foreach (PhotoTag ptag in phototags)
{
if (photofeqlist.Exists(delegate(PhotoFeq pf) { return pf.PhotoName == ptag.Tag; }))
{
photofeqlist.Find(delegate(PhotoFeq pq) { return pq.PhotoName == ptag.Tag; }).Count += 1;
}
else
{
photofeqlist.Add(new PhotoFeq(ptag.Tag, 1));
}
}
//search object by comparison
int j = phototags.BinarySearch(new PhotoTag(1202, "kiki"), new PhotoTagComparer());
Response.Write(phototags[j].PhotoID);
//get distinct in list
List<PhotoTag> distinctPhotoTag = phototags.Distinct(new PhotoTagEqualityComparer()).ToList<PhotoTag>();
}
}
}