Visual Studio를 사용하여 C#에서 asp.net 웹 응용 프로그램을 만드는 중입니다.Response.Write 스크립트 알림 상자가 asp.net 웹 양식에서 제대로 작동하지 않습니다.
이전 게시물에서는 asp.net의 팝업 메시지 상자에 대해 묻고 있었고 webforms에는없는 것으로 나타났습니다. Response.Write ("alert ('Hello world');");를 사용하여 빠른 픽스가 제공되었습니다. 이 기능은 새 페이지를 열 때 로그인 확인으로 한 번 사용하면 충분합니다. 내가 겪고있는 문제는 버튼 클릭 이벤트 내에 if 문이 여러 개 있고 첫 번째 스크립트 경고 만 작동한다는 것입니다 (if (poundRadBtn.Checked)). 다른 사람이 왜 효과가 없으며 고치거나 다른 대안이 있다면 왜 누군가가 내게 설명 할 수 있을까요? 미리 감사드립니다!
protected void submitPayBtn_Click(object sender, EventArgs e)
{
if (poundRadBtn.Checked)
if (cardList.Text == "" || cardNameBox.Text == "" || cardBox1.Text == "" || cardBox2.Text == "" || cardBox3.Text == "" || cardBox4.Text == "" || expMonList.Text == "" || expYrList.Text == "" || billNameBox.Text == "" || billAdd1Box.Text == "" || billAdd2Box.Text == "" || billCtyBox.Text == "" || billPostBox.Text == "" || billCntryBox.Text == "")
{
Response.Write("<script>alert('Please ensure all fields have an entry');</script>");
}
else if (usdolRadBtn.Checked)
if (cardList.Text == "" || cardNameBox.Text == "" || cardBox1.Text == "" || cardBox2.Text == "" || cardBox3.Text == "" || cardBox4.Text == "" || expMonList.Text == "" || expYrList.Text == "" || billNameBox.Text == "" || billAdd1Box.Text == "" || billAdd2Box.Text == "" || billCtyBox.Text == "" || billPostBox.Text == "" || billCntryBox.Text == "")
{
Response.Write("<script>alert('Please ensure all fields have an entry');</script>");
}
else if (ozdolRadBtn.Checked)
if (cardList.Text == "" || cardNameBox.Text == "" || cardBox1.Text == "" || cardBox2.Text == "" || cardBox3.Text == "" || cardBox4.Text == "" || expMonList.Text == "" || expYrList.Text == "" || billNameBox.Text == "" || billAdd1Box.Text == "" || billAdd2Box.Text == "" || billCtyBox.Text == "" || billPostBox.Text == "" || billCntryBox.Text == "")
{
Response.Write("<script>alert('Please ensure all fields have an entry');</script>");
}
else if (ozdolRadBtn.Checked)
if (cardList.Text == "" || cardNameBox.Text == "" || cardBox1.Text == "" || cardBox2.Text == "" || cardBox3.Text == "" || cardBox4.Text == "" || expMonList.Text == "" || expYrList.Text == "" || billNameBox.Text == "" || billAdd1Box.Text == "" || billAdd2Box.Text == "" || billCtyBox.Text == "" || billPostBox.Text == "" || billCntryBox.Text == "")
{
Response.Write("<script>alert('Please ensure all fields have an entry');</script>");
}
}
제 1 및 다른 사람 사이에 어떤 차이가없는 것 : 비어있는 다른 문으로 재 작성
는이 문제를 해결하는 한 가지 방법입니다. 다른'Response.Write' 라인이 실제로 히트되고 있는지 디버깅 해 봤나? – johna다른 응답. 쓰기가 맞지 않습니다. 레이블을 추가하고 텍스트를 설정하여 테스트했습니다. 나는 그것을 얻지 못한다. 코드는 각 라디오 버튼에 복사하여 붙여 넣는다. 그래서 하나가 작동한다면, 왜 그들 모두를하지 않겠는가? – ACostea
다른 응답 파일이 적중되지 않으면 문제는'if' 행과 같아야합니다. 디버깅하는 동안 각 줄을 밟아서 if 행에서 디버깅하는 동안 값을 확인 했습니까? – johna