Showing posts with label JQuery. Show all posts
Showing posts with label JQuery. Show all posts

Tuesday, 22 May 2012

Retrieving the content of a GridView cell.

 You often need to retrieve the gridview cell content and you write the long code in your code behind.

Below mentioned script are used to retrieve the cell content of gridview on click.

<script language="javascript" type="text/javascript">
$(document).ready(function() {
$("#<%=GridView.ClientID%> tr").filter(":not(:has(table, th))").click(function(e)
{
var $cell = $(e.target).closest("td"); $("#<%=GridView1.ClientID%> td"). removeClass("highlight"); $cell.addClass("highlight"); $("#message").text('You have selected: ' + $cell. text());
});
});
</script>

Post By : Dipen Shah
Blog By : Dipen Shah
Stay Connected...

Monday, 21 May 2012

Validating CheckboxList using Jquery

Below script is useful when you want to validate the checkboxlist control.
You just need to add below function on page.

<script language="javascript" type="text/javascript">
function CheckBoxList1_Validation(sender, args)
{
args.IsValid = false;
var cnt = $("#CheckBoxList1 input:checked").length;
args.IsValid = (cnt >= 3);
}
</script>


Post By : Dipen Shah
Blog By : Dipen Shah
Stay Tuned...

Saturday, 19 May 2012

Disallowing cut/copy/paste operations on a TextBox

Below is the simple jquery to not allow user to cut/copy/paste operations on a TextBox

<script type="text/javascript">
$(document).ready(function() {
$('#<%=txtNewPwd.ClientID%>').bind('cut copy paste',
function(e) {
e.preventDefault();
alert("Cut / Copy / Paste disabled in this textbox");
});
$('#<%=txtConfirmNewPwd.ClientID%>').bind('cut copy
paste', function(e) {
e.preventDefault();
alert("Cut / Copy / Paste disabled in this textbox
too!");
});
});
</script>

Post By : Dipen shah
Stay Tuned