http://geekswithblogs.net/QuandaryPhase/archive/2009/02/13/asp.net-listview-displaying-hierarchical-data.aspx
Balaji Selvarajan's
Routine work is enemy
Friday, 24 May 2013
Tuesday, 16 October 2012
Validation of Check box List
protected void Button1_Click(object sender, EventArgs e)
{
int i = 0;
if (CheckBoxList1.Items[0].Selected){ i++; }
if (CheckBoxList1.Items[1].Selected){ i++; }
if (CheckBoxList1.Items[2].Selected){ i++; }
if (CheckBoxList1.Items[3].Selected){ i++; }
if (CheckBoxList1.Items[4].Selected){ i++; }
if (i > 1)
{
Response.Redirect("abc.aspx");
}
else
{
Response.Write("check minimum 2 checkboxes........");
}
}
Checking Extension While Uploading
if (FileUpload1.FileName != "")
{
string ext = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
if (!(ext == ".jpg" || ext == ".png" || ext == ".gif"))
{
lblMessage.Text = "Sorry! Image can be JPG,PNG,GIF only";
return;
}
if (FileUpload1.FileBytes.Length > 150000)
{
lblMessage.Text = "Sorry! Image can be upto 150KB only";
return;
}
}
Allow Numeric
Java Script Validation allow Only Alpha Numeric
<script type="text/javascript">
$(function () {
$('input.alpha[$id=tb1]').keyup(function () {
if (this.value.match(/[^a-zA-Z0-9 ]/g)) {
this.value = this.value.replace(/[^a-zA-Z0-9 ]/g, '');
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="bigDiv">
<h2>Allow Only Alphanumeric Characters in a TextBox</h2>
<asp:TextBox ID="tb1" runat="server" class="alpha"
Text="Try entering Non alphanumeric char"
ToolTip="Try entering Non alphanumeric char"/>
<br /><br />
Tip: Examples of some non-alphanumeric characters <br />
are ~!@~#$%^&* and so on.
</div>
</form>
</body>
Subscribe to:
Posts (Atom)