问题描述
我有一个经典的ASP.NET 4.0项目命名为PicView一个ascx控件。它的开头是这样的:
<脚本=服务器>
公众的ImageUrl作为字符串
,这意味着我们可以在aspx页面使用控件的ImageUrl属性。要使用该控件,我下面的指令添加到aspx页面:
<%@注册标签preFIX =X变量名=PicViewSRC =〜/ ASCX / PicView.ascx%GT;
,再后来在ASPX体使用这样的控件:
< X:PicView的ImageUrl =IMG / BLA-bla.jpg=服务器/>
但是,Visual Studio中的自动内置ASP.NET验证始终报告以下问题:
I get tons of these warning messages for my real-world project. I have not managed to do anything that could help VS to understand that my code is correct, so I wonder is there a way to turn this validation off?
Note that I need to turn off only the ASP.NET validation, but not the specific HTML version validation for this project. Sure, if you can tell me how to make this validation working in my situation, it would be very nice.
ImageUrl
needs to be a property, rather than a field, for example:
Public Property ImageUrl As String
Get
Return _imageUrl
End Get
Set(value As String)
_imageUrl = value
End Set
End Property
Private _imageUrl As String
If you want to be able to modify the property in code, and have it persisted across a PostBack, you should use ViewState to store its value, e.g.:
Public Property ImageUrl As String
Get
Return ViewState("imageUrl")
End Get
Set(value As String)
ViewState("imageUrl") = value
End Set
End Property
这篇关于如何在VS ASPX逃跑ASP.NET验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!