更新面板中的ajax控制工具包水印扩展器
我有一个最初加载下拉列表的网页。当从列表中选择一个项目时,会在更新面板异步回发期间动态创建一个 Web 表单。
我向某些文本框添加了水印扩展器,但首次更新页面时不显示水印。如果我将注意力集中然后移出其中一个文本框,水印就会出现并且似乎工作正常。通过检查源代码,我发现客户端创建的水印被附加到客户端上 Sys.Application 的 init 事件中。
这就是我感到困惑的地方。 1. 我向客户端页面 Sys.Application.initialize 事件添加了一个处理程序,以查看它是否在异步回发的生命周期期间被调用。它似乎没有引发该事件。 2. 我尝试通过向 PageRequestManager End Request 方法添加处理程序来引发初始化事件,但检查页面是否已初始化的标志已设置,因此没有触发任何单个处理程序。 3. 1 & 之后2,我认为当我将焦点应用于水印扩展器时,它可能以某种方式被延迟加载。所以我把应该在initialize事件中执行的$create语句放在PageRequestManager的End Request事件中。客户端脚本抛出错误,因为水印扩展器显然已经创建。
除了编写我自己的水印代码之外,我不确定这里的分辨率是什么。这是一个限制吗(扩展器只有在页面的初始请求中创建才能正常运行)吗?那么 init 事件呢?我看不到它发射,但如果扩展器已经创建,它一定有???
任何帮助将不胜感激。谢谢。
I have a web page that initially loads a drop down list. When an item is selected from the list, a web form is dynamically created during an update panel async postback.
I added watermark extenders to some of the textboxes, but the watermark does not display when the page is first updated. If I focus in and then out of one of the textboxes, the watermark then appears and seems to work fine. From examining the source, I saw that the client side creation of the watermark was being attached to the init event of Sys.Application on the client.
Here's where I'm getting confused.
1. I added a handler to the client side page Sys.Application.initialize event to see if it was called during the life cycle of an async postback. It didn't appear to fire the event.
2. I tried to raise the initialize event by adding a handler to the PageRequestManager End Request method, but the flags that check if the page was already initialized were set, so none of the individual handlers were fired.
3. After 1 & 2, I thought maybe the watermark extender was somehow being lazy loaded when I applied focus to it. So I put the $create statement that is supposed to be executed in the initialize event in the End Request event of the PageRequestManager. The client script threw an error because the watermark extender was apparantly already created.
I'm not sure what the resolution here is, outside of writing my own watermark code. Is this a limitation (will the extender only function correctly if created in the initial request for the page)? And what about the init event? I can't see it firing, but if the extender was already created, it must have???
Any help would be appreciated. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
水印扩展也让其他人头疼。我建议看一下 jquery 水印插件 http://jquery-watermark.googlecode.com/
The watermark extension gives headaches to others too. I'd suggest taking a look at a jquery watermark plugin http://jquery-watermark.googlecode.com/