简体   繁体   English

如何在ASP.NET VB项目中获取控件的Handle?

[英]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.

相关问题 如何在ASP.NET网站项目中使用最新的VB.NET语言级别? - How can I use the latest VB.NET language level in an ASP.NET web site project? 如何找到特定的Image Control并设置其ImageUrl属性(ASP.net-vb) - How can i find specific Image Control and set its ImageUrl property (ASP.net - vb) 如何更改 Ajax 文件上传控件、Asp.net(VB) 中的文件信息? - How can I change File Info in Ajax File Upload Control ,Asp.net(VB)? 为什么我的电话的 IP 地址报告不同(取决于站点),我如何以编程方式在 ASP.Net 中获得一致的地址? - Why is my phone's IP address reported differently (depending on the site) and how can I programmatically obtain a consistent one in ASP.Net? 如何在 Visual Studio 2019 中添加 Adobe Pdf 查看器(Asp.net Vb.net 项目)? - How can I add Adobe Pdf viewer in Visual Studio 2019( Asp.net Vb.net Project)? C#:如何将Memory stream设置为asp.net图像控件的source属性? - C# :How can i set Memory stream as the asp.net image control's source property? 如何获取asp.net mvc项目中所有页面的列表 - How do I obtain a list of all of the pages within an asp.net mvc project 当我在VB.net中单击Web窗体的任何空间时,如何在ASP.net中隐藏按钮控件 - How to hide a button control in ASP.net when I click in any space of the webform in VB.net 如何将onclick添加到asp.net中的通用控件? - How can I add an onclick to a generic control in asp.net? ASP.NET MVC:如何将控件呈现给流? - ASP.NET MVC: How can I render a Control to a Stream?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM