ASP.NET验证是客户端或服务器端

问题描述:

我做谷歌搜索我得到了这样的结果



1.这里有标签有runat =Server所以这些是服务器端控件

2.这些都是客户端和服务器端



supose它是(客户端和服务器端)



然后有些人使用JavaScript进行验证为什么?





任何人都可以澄清我的怀疑

i did Google search i got the results like this

1. here in tag there is runat="Server" so these are server side controls
2. These are both Client and Server side

supose it is both(Client and Server)

Then some of people using JavaScript for validations why?


Can any one please clarify my doubt

ASP.Net验证控件是服务器端控件,这意味着您可以在C#代码中设置它们的值。但是,实际验证是在客户端进行的。



有些人使用JavaScript,因为它为您提供了更大的灵活性。这完全取决于你想做什么。没有正确或错误的方法。



但是,即使您验证客户端,您仍应始终验证服务器端,因为客户端可以由user。
ASP.Net validation controls are server side controls, meaning you can set values on them in C# code. However, the actual validation takes place on the client side.

Some people use JavaScript because it gives you more flexibility. It just all depends on what you want to do. There is no right or wrong way to do it.

However, even though you validate client side you should still always validate server side because client side can be manipulated by the user.


验证控件是服务器端,因为您知道我们使用runat =server但它在客户端执行验证。
Validation controls are server side as you know we use runat = "server" but it''s perform validation at client side.