1. Check Radio button list value using JQuery and display message.
function rblStatus()
{
var rss = $('#<%=RadioButtonList.ClientID %> input[type=radio]:checked').val();
if (rss != 'Pending' && rss != 'Updated' && rss != 'Disapproved')
{
msg = "Please Select Status";
alert(msg);
return false;
}
else
{
return true;
}
}
2. Jquery Code to check all checkboxes in a gridview
function SelectAllCheckboxes(chk)
{
$('#<%=gridview.ClientID%>').find("input:checkbox").each(function ()
{
if (this != chk) { this.checked = chk.checked; }
});
}
3. Show / Hide Any server control using Jquery
$("#<%=ASPControlName.ClientID%>").css("display", "none"); //Hide
$("#<%=ASPControlName.ClientID %>").css("display", "block"); //Show
4. Uncheck ASP RadioButtonList
$("table[id$=ASPControlName] input:radio:checked").removeAttr("checked")
5. Assign Value to an ASPControl
$("#<%=ddlStatus.ClientID %>").val('USERVALUE'); //USERVALUE can be any varchar value.
6. Find Gridview row count
var gvCount = $("#<%=Gridview.ClientID %> tr").length;
if (gvCount > 0)
{
alert("Count is:"+gvCount );
}
else
{
alert("No rows available");
}
7. Print data in using client side Code using JavaScript
Step 1: Create table to be displayed under div.
<div id="div1" runat="server" visible="false">
<table border="1" cellpadding="1" cellspacing="1" id="PrintSlot" align="center">
<tr>
<td align="center" >
<asp:Label ID="Label6" runat="server" Text="Print Me"></asp:Label>
</td>
</tr>
</table>
</div>
Step 2: JavaScript Function to print the content.
function printData()
{
var divToPrint = document.getElementById("PrintSlot"); // Pass ID of table
newWin = window.open("");
newWin.document.write(divToPrint.outerHTML);
newWin.print();
}
function rblStatus()
{
var rss = $('#<%=RadioButtonList.ClientID %> input[type=radio]:checked').val();
if (rss != 'Pending' && rss != 'Updated' && rss != 'Disapproved')
{
msg = "Please Select Status";
alert(msg);
return false;
}
else
{
return true;
}
}
2. Jquery Code to check all checkboxes in a gridview
function SelectAllCheckboxes(chk)
{
$('#<%=gridview.ClientID%>').find("input:checkbox").each(function ()
{
if (this != chk) { this.checked = chk.checked; }
});
}
3. Show / Hide Any server control using Jquery
$("#<%=ASPControlName.ClientID%>").css("display", "none"); //Hide
$("#<%=ASPControlName.ClientID %>").css("display", "block"); //Show
4. Uncheck ASP RadioButtonList
$("table[id$=ASPControlName] input:radio:checked").removeAttr("checked")
5. Assign Value to an ASPControl
$("#<%=ddlStatus.ClientID %>").val('USERVALUE'); //USERVALUE can be any varchar value.
6. Find Gridview row count
var gvCount = $("#<%=Gridview.ClientID %> tr").length;
if (gvCount > 0)
{
alert("Count is:"+gvCount );
}
else
{
alert("No rows available");
}
7. Print data in using client side Code using JavaScript
Step 1: Create table to be displayed under div.
<div id="div1" runat="server" visible="false">
<table border="1" cellpadding="1" cellspacing="1" id="PrintSlot" align="center">
<tr>
<td align="center" >
<asp:Label ID="Label6" runat="server" Text="Print Me"></asp:Label>
</td>
</tr>
</table>
</div>
Step 2: JavaScript Function to print the content.
function printData()
{
var divToPrint = document.getElementById("PrintSlot"); // Pass ID of table
newWin = window.open("");
newWin.document.write(divToPrint.outerHTML);
newWin.print();
}
No comments:
Post a Comment