重要ㄉ小老鼠
原程式如下:
if(txtTop.Text.Trim() == "" txtTestDateStart.Text.Trim() == "" !CheckInt(txtTop.Text.Trim()))
{
if(txtTestDateStart.Text.Trim() == "")
{
ErrorMessage += "請輸入測試日期n";
}
if(txtTop.Text.Trim() == "")
{
ErrorMessage += "請輸入顯示TOP資料n";
}
else
{
ErrorMessage += "顯示TOP資料只能為>0的整數n";
}
String scriptString1 = string.Format(@"
<script language=JavaScript>
<!-- begin
alert('{0}')
//end -->
</script>
",ErrorMessage);this.RegisterStartupScript("s",scriptString1);
修改後:
if(txtTop.Text.Trim() == "" txtTestDateStart.Text.Trim() == "" !CheckInt(txtTop.Text.Trim()))
{
if(txtTestDateStart.Text.Trim() == "")
{
ErrorMessage += @"請輸入測試日期n";
}
if(txtTop.Text.Trim() == "")
{
ErrorMessage += @"請輸入顯示TOP資料n";
}
else
{
ErrorMessage += @"顯示TOP資料只能為>0的整數n";
}
String scriptString1 = string.Format(@"
<script language=JavaScript>
<!-- begin
alert('{0}')
//end -->
</script>
",ErrorMessage);this.RegisterStartupScript("s",scriptString1);
差別在ErrorMessage後的"@",不使用時會造成javascript結尾錯誤
很機車ㄉ錯誤~~差點去買乖乖來拜了>"<
沒有留言:
張貼留言