若是一个page1.aspx向page2.aspx提交的流程,则在page2.aspx的顶部添加如下声明:
<%@ PreviousPageType VirtualPath="~/page1.aspx" %>
设置page1.aspx的PostbackUrl属性为~/page2.aspx。
假设page1.aspx的codebehind中有名为test()的方法,则在page2.aspx中可以这样调用:
if (PreviousPage != null && PreviousPage.IsCrossPagePostBack)
{
return ((page1)PreviousPage).test();
}
顺便记录一下注册客户端脚本的方法:
static readonly string script = "<script language=\"javascript\">\n" +
"alert (\"Sorry, but we couldn't validate your credit card\");\n" + "</script>";
ClientScript.RegisterStartupScript(script.GetType(), "Error", script);
------------------------------------------
<%@ PreviousPageType VirtualPath="~/page1.aspx" %>
设置page1.aspx的PostbackUrl属性为~/page2.aspx。
假设page1.aspx的codebehind中有名为test()的方法,则在page2.aspx中可以这样调用:
if (PreviousPage != null && PreviousPage.IsCrossPagePostBack)
{
return ((page1)PreviousPage).test();
}
顺便记录一下注册客户端脚本的方法:
static readonly string script = "<script language=\"javascript\">\n" +
"alert (\"Sorry, but we couldn't validate your credit card\");\n" + "</script>";
ClientScript.RegisterStartupScript(script.GetType(), "Error", script);
------------------------------------------
和以前的用法有点不同,所以记录下来了。
ArrayList list = new ArrayList();
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox box = (CheckBox)row.Cells[3].Controls[1];
if (box.Checked)
list.Add(row.Cells[0].Text);
}
return list;
Dim list As ArrayList = New ArrayList()
For Each row As GridViewRow In GridView1.Rows
Dim box As CheckBox = CType(row.Cells(3).Controls(1), CheckBox)
If (box.Checked) Then
list.Add(row.Cells(0).Text)
End If
Next
Return list
ArrayList list = new ArrayList();
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox box = (CheckBox)row.Cells[3].Controls[1];
if (box.Checked)
list.Add(row.Cells[0].Text);
}
return list;
Dim list As ArrayList = New ArrayList()
For Each row As GridViewRow In GridView1.Rows
Dim box As CheckBox = CType(row.Cells(3).Controls(1), CheckBox)
If (box.Checked) Then
list.Add(row.Cells(0).Text)
End If
Next
Return list