我正在使用javascript创建一个验证来验证1到100之间的页面大小。如果errorCtr = 0然后在codebenhind中调用GotoPage()。提前谢谢你。
<script type="text/javascript" language="javascript">
function validatePageSize() {
var pageSize = document.getElementById('MainContent_txtPageSize').value;
var errorCtr = 0;
if (pageSize == "") {
alert('Records per page should be a valid number');
errorCtr++;
}
if (pageSize < 0 || pageSize > 100) {
alert('Records per page should be between 1 to 100');
errorCtr++;
}
if (errorCtr == 0) {
//missing code
}
}
</script>
代码隐藏:
void GotoPage()
{
if (txtPageSize.Text.Trim() != "0" && txtPageSize.Text.Trim().Length > 0)
{
GridView1.PageSize = Convert.ToInt16(txtPageSize.Text.Trim());
GetPOHistoryByParameterOrderByPONumber();
btnShowAll.Visible = false;
}
else
{
GridView1.PageSize = 100;
GetPOHistoryByParameterOrderByPONumber();
btnShowAll.Visible = false;
txtPageSize.Text = "100";
}
}