<%@ OutputCache Duration="60" VaryByParam="none" VaryByCustom="browser"
Shared="true %>
该示例将缓存用户控件 60 秒,并且将针对每个浏览器名称和主要版本创建一个缓存条目。然后,每个浏览器的缓存条目将由引用此用户控件的所有页面共享(只要所有页面都用相同的 ID 引用该控件即可)。以上红色文字是不是说明引用该用户控件的所有页面必须给该用户控件一个相同的ID号,才能达到共享该用户控件的缓存???
Shared="true %>
该示例将缓存用户控件 60 秒,并且将针对每个浏览器名称和主要版本创建一个缓存条目。然后,每个浏览器的缓存条目将由引用此用户控件的所有页面共享(只要所有页面都用相同的 ID 引用该控件即可)。以上红色文字是不是说明引用该用户控件的所有页面必须给该用户控件一个相同的ID号,才能达到共享该用户控件的缓存???
tx_extime.Value = Kminfo[3];
string lst = roandow_data(mySet.Tables[0].Rows.Count, int.Parse(Kminfo[1]));
txID.Text = lst;
txVuale.Text = Kminfo[2];
string[] lsts=lst.Split(';');
for (int i=0;i<lsts.Length;i++)
{
Table ntb = new Table();
TD1.Controls.Add(ntb);
TableRow ntr = new TableRow();
ntb.Controls.Add(ntr);
TableCell ntc = new TableCell();
ntr.Controls.Add(ntc);
Label nlb = new Label();
nlb.Font.Bold = true;
nlb.Font.Size = 11;
nlb.Text = (i+1).ToString() + "、" + mySet.Tables[0].Rows[int.Parse(lsts[i])]["q_question"].ToString();
ntc.Controls.Add(nlb);
ntr = new TableRow();
ntb.Controls.Add(ntr);
ntc = new TableCell();
ntr.Controls.Add(ntc);
RadioButtonList nrbl = new RadioButtonList();
for (char ia = 'A'; ia <= 'D'; ia++)
{
ListItem li = new ListItem();
li.Text = ia.ToString() + "、" + mySet.Tables[0].Rows[int.Parse(lsts[i])]["q_key" + ia.ToString()].ToString();
li.Value = ia.ToString();
nrbl.Items.Add(li);
}
nrbl.ID = "q_" + mySet.Tables[0].Rows[int.Parse(lsts[i])]["q_id"].ToString();
ntc.Controls.Add(nrbl);
}
Button1.Visible = true;
}
private string roandow_data(int allcount, int thecount)
{
Random rnd = new Random();
List<int> lst = new List<int>();
int i = 0;
string str = "";
while (i < thecount)
{
int j = rnd.Next(allcount);
if (lst.IndexOf(j) == -1)
{
lst.Add(j);
i++;
}
}
foreach (int j in lst)
{
if (str.Length == 0)
{
str = j.ToString();
}
else
{
str = str + ";" + j.ToString();
}
}
return str;哪位能够解答下!!
你理解错误注意看 这里
VaryByParam="none" VaryByCustom="browser"
VaryByParam 针对不同的参数缓存不同的内容,
比如.你处控件需要处理新闻栏目并缓存相应的数据,那里这里就要把不同的新闻栏目ID传进来,根据不同的ID输出不同的缓存内容
要是我没记错.这里的param指的是Request集合的一些内容,包括了get 与 post ,但是请具体查一下msdnVaryByCustom="browser"
针对不同的自定义内容缓存不同的内容
这里的browser 就是浏览器了...你多看看msdn吧,你看的这个缓存的例子,扯蛋的很,重要的不写,写个非重要的按浏览器缓存.
除非VaryByParam="*"才表示request过来的参数有变化的话该缓存就失效,它所谓的引用该用户控件的ID不是你理解的request过来的ID,呵呵,所以我才有了这个疑问,我认为它的说法是错误的,它意思是用户控件的ID只有相同才能共享该缓存,可是我测试后好象跟这个ID没关系
所以来请教....