iT邦幫忙

0

ASP.NET C# 登入程式碼異常

網上找了些資料 , 還是看不出來哪裡有問題 , 請教大家幫我看看

https://ithelp.ithome.com.tw/upload/images/20181230/20104326V7R0ogyp35.png

https://ithelp.ithome.com.tw/upload/images/20181230/201043262tV2WKkjsT.png

看更多先前的討論...收起先前的討論...
不明 檢舉
他的錯誤寫的是什麼
alex9453 iT邦新手 2 級 ‧ 2018-12-31 18:42:31 檢舉
改這樣可以了

protected void enter_Click(object sender, EventArgs e)
{
if (TextName.Text == "root" & txtPass.Text == "1234")
{
Session["name"] = TextName.Text;
Session["password"] = txtPass.Text;
Response.Redirect("FruitsMap.aspx");
}
else {
error.Text = "帳號密碼有誤 !";
}
}
aptx1596 iT邦新手 4 級 ‧ 2019-01-04 21:16:09 檢舉
&&沒問題嗎
aptx1596 iT邦新手 4 級 ‧ 2019-01-04 21:16:10 檢舉
丟到Visual Studio / Visual Code 看一看 應該就都出來了 說到這裡,TIPTOP 程式編輯,原廠的教學中也沒有任何編輯器可以看到紅色蚯蚓 後來編輯器之後,卻不能正常地顯示錯誤 語法錯誤不會自動檢查。
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中
1
PPTaiwan
iT邦好手 1 級 ‧ 2018-12-31 09:16:31
最佳解答

建議你 >>

  1. 別用 Session 來做記錄這是壞習慣,Session 可以用但別大量用,隨時隨地就創出一個 Session 內容都不知道這是從那裡創出來的..

  2. 使用 強型別 做相關資料的資料傳遞。

  3. 多使用 JSON 來做往後的學習與應用。

  4. 學習一下資料庫預存程序與 JSON 的配合應用,將對於你往後的學習有很重要的發展

alex9453 iT邦新手 2 級 ‧ 2018-12-31 18:43:50 檢舉

改這樣可以了 , 謝謝你的回覆

protected void enter_Click(object sender, EventArgs e)
    {
        if (TextName.Text == "root" & txtPass.Text == "1234")
        {
            Session["name"] = TextName.Text;
            Session["password"] = txtPass.Text;
            Response.Redirect("FruitsMap.aspx");
                   }
        else {
            error.Text = "帳號密碼有誤 !";
        }
    }
1
Homura
iT邦高手 1 級 ‧ 2018-12-31 00:25:29

老實說下面那段程式碼到底是什麼
有JS的script標籤
但裡面又是C#程式碼....
然後你的方法還沒用大括號框起來....
而且if條件還只有一個等於
你是來亂的嗎?

看更多先前的回應...收起先前的回應...
froce iT邦大師 1 級 ‧ 2018-12-31 10:04:53 檢舉

你記住這個ID,你就知道他是不是來亂的了。

Homura iT邦高手 1 級 ‧ 2018-12-31 11:14:12 檢舉

froce
我只是想抱怨一下而已/images/emoticon/emoticon39.gif

不明 檢舉

如果沒有cs檔的話的確可以用script包住加個runat="server"

Homura iT邦高手 1 級 ‧ 2019-01-01 14:02:36 檢舉

Windows Hello
如果這樣寫的話等於回到asp的寫法
webform前後端切開的寫法等於沒意義了/images/emoticon/emoticon16.gif

alex9453 iT邦新手 2 級 ‧ 2019-01-01 14:22:23 檢舉

改這樣可以了 , 謝謝你們的回覆

protected void enter_Click(object sender, EventArgs e)
    {
        if (TextName.Text == "root" & txtPass.Text == "1234")
        {
            Session["name"] = TextName.Text;
            Session["password"] = txtPass.Text;
            Response.Redirect("FruitsMap.aspx");
                   }
        else {
            error.Text = "帳號密碼有誤 !";
        }
    }
0
焦阿
iT邦新手 5 級 ‧ 2018-12-31 12:31:02

單純是你的事件開頭少了{

alex9453 iT邦新手 2 級 ‧ 2018-12-31 17:37:34 檢舉

你是說這樣嗎 ?
https://ithelp.ithome.com.tw/upload/images/20181231/20104326jWUem2V6aO.png

alex9453 iT邦新手 2 級 ‧ 2018-12-31 18:42:02 檢舉

改這樣可以了 , 謝謝你的回覆

protected void enter_Click(object sender, EventArgs e)
    {
        if (TextName.Text == "root" & txtPass.Text == "1234")
        {
            Session["name"] = TextName.Text;
            Session["password"] = txtPass.Text;
            Response.Redirect("FruitsMap.aspx");
                   }
        else {
            error.Text = "帳號密碼有誤 !";
        }
    }

我要發表回答

立即登入回答