以下代码用于使用Custom Validator验证DropDownList控件.
Default1.aspx
<td>
<asp:DropDownList ID="DDL_Product" runat="server" Height="21px" Width="128px">
<asp:ListItem>Select</asp:ListItem>
<asp:ListItem>Nokia</asp:ListItem>
<asp:ListItem>LG</asp:ListItem>
<asp:ListItem>Samsung</asp:ListItem>
<asp:ListItem>sony</asp:ListItem>
<asp:ListItem>Micromax</asp:ListItem>
<asp:ListItem>Karbonn</asp:ListItem>
<asp:ListItem>Apple</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:CustomValidator ID="cv1" Display="Dynamic" ControlToValidate = "DDL_Product" OnServerValidate="ddl_server" runat="server" ForeColor="Red" ErrorMessage="Please Select the Product"></asp:CustomValidator>
</td>
Run Code Online (Sandbox Code Playgroud)
Default1.aspx.cs
protected void ddl_server(object sender, ServerValidateEventArgs e)
{
if (e.Value.selectedIndex <= 0)
{
e.IsValid = true;
}
else
{
e.IsValid = false;
}
}
Run Code Online (Sandbox Code Playgroud)
以上验证未经验证.我不知道如何使用此控件并验证DropDownList.请更正错误.
使用JavaScript或jQuery动态加载div标签内的html页面.
<html>
<head>
<title>Untitled Document</title>
</head>
<script type="text/javascript">
$(document).ready(function(){
$('#btn').click(function(){
$('#div_content').html('C:/xampp/htdocs/ex1.html');
});
});
</script>
<body>
<input type="button" id="btn" value="Load" />
<div id="d_content">
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
但它没有工作..