We are happy to announce the availability of .NET 8, the latest LTS version of one of the world’s leading development platforms, starting today. .NET 8 delivers thousands of performance, stability, and security improvements, as well as platform and tooling enhancements that help increase developer productivity and speed of innovation
اشتراکها
اشتراکها
C# در مرورگر با Blazor
Blazor is the new Microsoft experimental framework that brings C# into any browser without a plug-in. It holds the promise of modern single-page applications, combined with the ability to use C# and its vast base-class library. Blazor takes C# development to a new level. It’s the final piece necessary to make the language a full-stack development tool. It will have all the power of the popular JavaScript frameworks, but based on the familiar languages, APIs and tooling of the Microsoft .NET Framework.
checkBoxList جزو کنترلهایی در ASP.Net است که نمیتوان RequiredFieldValidator استاندارد را بر آن اعمال کرد. به عبارتی اگر نیاز بود حداقل یک آیتم چک باکس لیست حتما توسط کاربر انتخاب شود، راه حل آمادهای برای آن وجود ندارد. پیاده سازی اینکار با استفاده از jQuery به سادگی میسر است که در ادامه آنرا مرور خواهیم کرد.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CheckBoxListValidator._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function CheckItems(sender, args) {
//Get the total nuumber of selected CheckBoxes
var num = jQuery("table#<%=CheckBoxList1.ClientID%> input:checked").length;
args.IsValid = num > 0;
}
//]]>
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
<asp:ListItem>item1</asp:ListItem>
<asp:ListItem>item2</asp:ListItem>
</asp:CheckBoxList>
<asp:CustomValidator ClientValidationFunction="CheckItems" ID="ValidateIt"
runat="server" ErrorMessage="(*)"> </asp:CustomValidator>
<asp:Button ID="Button1" runat="server" />
</div>
</form>
</body>
</html>
توضیحات:
یک CustomValidator استاندارد را به فرم اضافه کردهایم تا توسط تابعی که به ClientValidationFunction آن معرفی میشود، کار اعتبار سنجی سمت کاربر را انجام دهد. این تابع یا همان CheckItems مثال فوق، امضای استاندارد و آشنایی دارد. اگر تعیین اعتبار صورت گرفته باشد، باید args.IsValid در آن به true تنظیم شود یا بر عکس.
اصل قضیه هم، همین یک سطر کد زیر است:
var num = jQuery("table#<%=CheckBoxList1.ClientID%> input:checked").length;
اشتراکها
بررسی const در جاوااسکریپت
اشتراکها
آیا استفاده از Bool مضر است؟
اشتراکها
استفاده از WebSocket در دات نت
پیشنهادها
async scripts؛ خوب یا بد؟
منابع پیشنهادی
HTML script async Attribute
Load Non-blocking JavaScript with HTML5 Async and Defer
Async Attribute and Scripts At The Bottom
Script-injected "async scripts" considered harmful
the underestimated problem about script async attribute
Use Asynchronous Scripts
Deep dive into the murky waters of script loading
HTML5 Async Scripts
Can I use async
HTML script async Attribute
Load Non-blocking JavaScript with HTML5 Async and Defer
Async Attribute and Scripts At The Bottom
Script-injected "async scripts" considered harmful
the underestimated problem about script async attribute
Use Asynchronous Scripts
Deep dive into the murky waters of script loading
HTML5 Async Scripts
Can I use async
اشتراکها
آشنایی با NodeJS و MongoDB
اشتراکها