아래 코드는 귀하의 페이지와 비슷한 것을 얻을 수 있도록 도와줍니다. 이 작업을 수행하는 고전적인 방법의
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
</style>
<script type="text/javascript">
function ShowAlert()
{
var dropDownList = document.getElementById("DropDownList1");
var dropDownListValue = dropDownList.value;
if (dropDownListValue == "1")
{
alert('This is your message box!');
}
};
</script>
</head>
<body>
<form runat="server">
<asp:DropDownList ID="DropDownList1" runat="server" onchange="ShowAlert();">
<asp:ListItem Text="Yes" Value="1"></asp:ListItem>
<asp:ListItem Text="No" Value="0"></asp:ListItem>
</asp:DropDownList>
</form>
</body>
확인에
onchange
속성을 추가,하지만 어떻게 내가 사용자가 드롭 다운에 "예"선택 때 트리거받을 수 있나요 ? 또한, 이것은 aspx 페이지입니다, 자바 스크립트를 구현하는 코드는 어떻게 생겼을까요? – FluxEnginemdmullinax는 아마도 이것을 달성하는 가장 간단한 해답 일 것입니다. –
예. 가장 직선이지만 인라인 자바 스크립트처럼 인라인 CSS는 피해야합니다. 이유에 대해서는이 링크를 확인하십시오. http://robertnyman.com/2008/11/20/why-inline-css-and-javascript-code-is-such-a-bad-thing/ – anothershrubery