[英]i am getting this Exception “Parameter is not valid.at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)”
[英]Why am I getting a NaN is not a valid value of Int32 error?
更新:
我得到了同樣的錯誤。 當我點擊x
,它應該返回{id:23},但它返回{id: NaN}
。 如果我刪除三元運算符,此問題將自行糾正。
我對我的網頁進行了更改:
就是這樣:
$( "#notifications" ).prepend( "<div class='notification' id='n" + notifications.d[i].id + "'><span class='notification_text'>" + notifications.d[i].text + "</span><a href='#' class='notification_button' id='b" + notifications.d[i].id + "' value='x'>x</a></div>" ).show();
並且我將其更改為此,根據notifications.d[i].sticky
的值添加了三元條件:
$( "#notifications" ).prepend( "<div class='notification' id='n" + notifications.d[i].id + "'><span class='notification_text'>" + notifications.d[i].text + "</span>" + ( notifications.d[i].sticky ? "" : "<a href='#' class='notification_button' id='b'" + notifications.d[i].id + "' value='x'>x</a>'" ) + "</div>" ).show();
該部分工作正常,如果粘性為真,則不創建x
鏈接。
但是,當我點擊任何其他x
,我收到服務器端錯誤消息:
NaN is not a valid value of Int32
服務器端代碼如下所示:
[WebMethod()]
public int CloseNotification(int id) {
using (connection = new SqlConnection(ConfigurationManager.AppSettings["connString"])) {
using (command = new SqlCommand("update notifications set closed_by = @user where id = @id", connection)) {
command.Parameters.Add("@id", SqlDbType.Int, 4).Value = id;
command.Parameters.Add("@user", SqlDbType.VarChar, 4).Value = "abc";
connection.Open();
intAffectedRows = command.ExecuteNonQuery();
connection.Close();
}
}
return intAffectedRows;
}
任何人都知道我為什么會收到這個錯誤?
我認為我在三元組中犯了一個錯誤,可能是雙重或單引號錯誤,但我看不到它。
您讀取的代碼中的代碼中存在語法錯誤
id='b'" + notifications.d[i].id + "' value='x'>x</a>'" ) + "</div>" ).show();
在b
之后還有一個額外的'
。 它應該是:
id='b" + notifications.d[i].id + "' value='x'>x</a>'" ) + "</div>" ).show();
編輯 :
在三元操作結束時,您還需要額外的'
。
( notifications.d[i].sticky ? "" : "<a href='#' class='notification_button' id='b" + notifications.d[i].id + "' value='x'>x</a>'" )
應該:
( notifications.d[i].sticky ? "" : "<a href='#' class='notification_button' id='b" + notifications.d[i].id + "' value='x'>x</a>" )
在三元運算符中,您有一個單引號</a>
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.