[英]How can I obtain a control's Handle in a ASP.NET VB project?
I want to add Cue/Watermarks to my ASP:TextBox controls for a nicer user experience, and came across the very nice CueProvider, which has this VB-adjusted version which sadly I cannot compile. 我想提示/水印添加到我的ASP:TextBox控件的一个更好的用户体验,并跨越很不错CueProvider,其中有来到这个 VB-调整版本,遗憾的是我不能编译。
My class is as follows 我的课如下
#Region "Imports"
Imports System.Runtime.InteropServices
#End Region
Public Class Watermark
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)>
Private Shared Function SendMessage(ByVal hWnd As HandleRef,
ByVal Msg As UInteger,
ByVal wParam As IntPtr,
ByVal lParam As String) As IntPtr
End Function
Public Shared Sub [Set](ByVal ctl As Control, ByVal hintText As String)
Const EM_SETCUEBANNER As Int32 = &H1501
Dim retainOnFocus As IntPtr = New IntPtr(1)
Dim msg As Int32 = EM_SETCUEBANNER
SendMessage(New HandleRef(ctl, ctl.Handle), msg, retainOnFocus, hintText)
End Sub
End Class
The compile failure is on the New HandleRef(ctl, ctl.Handle)
that second parameter is apparently not a valid property. 编译失败是在
New HandleRef(ctl, ctl.Handle)
,第二个参数显然不是有效属性。
How I can get the windows handle of the incoming UI control? 如何获取传入UI控件的Windows句柄?
The code you have found is for Windows Forms, but you are developing an ASP.NET Web Forms application. 您找到的代码是Windows窗体的,但是您正在开发ASP.NET Web窗体应用程序。 Therefore it is not appropriate.
因此,这是不合适的。 You cannot obtain a window handle in ASP.NET.
您不能在ASP.NET中获得窗口句柄。
I believe what you're after is a placeholder. 我相信您所追求的是一个占位符。
<input type="text" placeholder="First Name" />
Or if you need a server control, 或者,如果您需要服务器控件,
<asp:TextBox runat="server" placeholder="First Name" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.