Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 alert message

Author  Topic 

shemayb
Posting Yak Master

159 Posts

Posted - 2007-10-11 : 16:46:54
hi,

i have this code which is displayed below, it should display an alert message when the button is clicked. The alert message will display if the dropdown list has no value. i have this error in my code:error CS1026: ) expected at...Can you take a look at it?thanks!

<asp:dropdownlist id="ddlDisciplineType" runat="server" Width="149px" AutoPostBack="True"></asp:dropdownlist>

<asp:button id="btnAssign" runat="server" Height="23px" Text="Assign" Onclick="javascript:assign();" Enabled="False"></asp:button


<script type="text/javascript" language="javascript">

function assign()
{

var vtype = gei('ddlVisitTypeItem').selectedIndex;
if (vtype.value == null || vtype.value == '')
return alert('test message');

}

</script>

Funnyfrog

rgombina
Constraint Violating Yak Guru

319 Posts

Posted - 2007-10-15 : 14:38:40
Here you go:


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>

<script type="text/javascript" language="javascript">

function assign()
{

var vtype = document.getElementById('ddlVisitTypeItem').selectedIndex;
if (vtype.value == null || vtype.value == '')
return alert('test message');

}

</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="ddlVisitTypeItem" runat="server" AutoPostBack="True" Width="149px"></asp:dropdownlist>

<asp:button id="btnAssign" runat="server" Height="23px" OnClientClick="assign();" Text="Assign" Enabled="true">
</asp:button>
</div>
</form>
</body>
</html>
Go to Top of Page
   

- Advertisement -