"暗黙的に型 'string'を 'int'に変換できません。エラーメッセージ "暗黙的に 'String'型を 'Int'に変換できません"
私はそのテキストを太字で表示しています。
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HttpCookie httpCookie = Request.Cookies["UserInfo"];
if (httpCookie == null)
{
txtDiv.Visible = true;
}
else
{
msgDiv.Visible = true;
string userName = httpCookie.Values["Name"].ToString();
WelcomeLabel.Text = "Welcome Back Mr. "+userName;
}
}
protected void SignupButton_Click(object sender, EventArgs e)
{
// Error in Below Line.
HttpCookie httpCookie = new HttpCookie["UserInfo"];
httpCookie.Values.Add("Name", NameTextBox.Text);
httpCookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(httpCookie);
Response.Redirect("Thanks.aspx?name="+NameTextBox.Text);
// Server.Transfer("Thanks.aspx");
}
また、新しいHttpCookie ["UserInfo"]に変更します。ToString();しかし、エラー.......あなたが実際にint
ことが期待されているindex
によってarray
からelement
にアクセスしようとしていると、あなたがエラーをスローname
ことによってそれをアクセスしているHttpCookie httpCookie = new HttpCookie["UserInfo"];
HttpCookie httpCookie = new HttpCookie("UserInfo");
に
ありがとう。 まあまあ、それは私の心の中で起こった質問です。int to string to int ........... !! –