62,047
社区成员
发帖
与我相关
我的任务
分享
<form id="form1" runat="server" method="post">
<div >
<input type="hidden" id="up" name="up" value="1" />
<%=text %>
</div>
</form>
function aa(){ var count =document.getElementById("up").value;
count--;}
function aa(){ var count =document.getElementById("up").value;
count--;}
protected static string text = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) {
//Response.Write("<script>window.alert(1____" + Request.Url.AbsoluteUri.Substring(Request.Url.AbsoluteUri.IndexOf('=')+1) + "____2);</script>");
DataTable data = new DataTable();
if (Request.Form["up"].ToString != "")
{
Response.Write("<script>window.alert(-------" + Request.Form["up"].ToString() + "________);</script>");
data = Bind(10, Convert.ToInt32(Request.Form["up"].ToString()), 10);
}
else {
data = Bind(10,1,10);
}
StringBuilder strText = new StringBuilder();
strText.Append("<table>");
for (int i = 0; i < data.Rows.Count;i++ )
{
strText.Append("<tr><td style=\"backgroundColor:red; border:1px red solid;\">");
strText.Append(""+data.Rows[i]["content"].ToString()+"");
strText.Append("</td></tr>");
}
strText.Append("<tr><td><a id=count1 name=count1 href=Default.aspx onclick='javascript:aa();'>上一页</a><a id=count2 name=count2 href=Default.aspx onclick='javascript:bb();'>下一页</a></td></tr>");
strText.Append("</table>");
string s = string.Empty;
text = strText.ToString();
}
Response.Write("<script>window.alert(-------" + Request.Form["up"].ToString() + "________);</script>");
}
private DataTable Bind(int pageSize,int page,int userId) {
StringBuilder strSql = new StringBuilder();
strSql.Append("SELECT TOP "+pageSize+" * ");
strSql.Append(" FROM sf_rq ");
strSql.Append(" WHERE rid NOT IN ");
strSql.Append(" ( ");
strSql.Append(" SELECT TOP ("+pageSize+" * ("+page+"-1)) rid FROM sf_rq ORDER BY rid ");
strSql.Append(" ) ");
strSql.Append(" and userid="+userId+" ");
strSql.Append(" ORDER BY enabledtime desc");
SqlConnection conn = new SqlConnection("uid=sa;pwd=123456;database=B2B;server=PC-201008201421");
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(strSql.ToString(), conn);
DataTable dt = new DataTable();
da.Fill(dt);
conn.Close();
return dt;
}
Request.Form["up"].ToString
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script type="text/javascript">
function test()
{
if(confirm("are you sure"))
{
document.getElementById("Hidden").value="true";
}
else
{
document.getElementById("Hidden").value="false";
}
alert(document.getElementById("Hidden").value);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="btn" runat="server" Text="Button" OnClientClick="test()" onclick="btn_Click" />
<asp:HiddenField ID="Hidden" runat="server" />
</form>
</body>
</html>