有没有办法将 Thickbox 与动态内容一起使用?
场景如下:
我的网页上有一个文本框和一个按钮。 单击该按钮时,我希望打开一个弹出窗口(使用 Thickbox),该窗口将显示与文本框中输入的值匹配的所有项目。 我目前正在使用 Thickbox 的 IFrame 实现。 问题是要显示的 URL 被硬编码到按钮的“alt”属性中。我真正需要的是“alt”属性将文本框中的值传递到弹出窗口。
这是到目前为止的代码:
<input type="textbox" id="tb" />
<input alt="Search.aspx?KeepThis=true&TB_iframe=true&height=500&width=700" class="thickbox" title="Search" type="button" value="Search" />
理想情况下,我想将文本框值放入 Search.aspx url,但我似乎不知道如何做到这一点,我当前的替代方案是使用 jQuery 设置“搜索”按钮的单击功能来调用 Web。然后,Search.aspx 页面将使用会话变量来执行搜索,这有点不稳定,因为搜索似乎总是有可能执行。在设置会话变量之前。
Here's the scenario:
I have a textbox and a button on a web page. When the button is clicked, I want a popup window to open (using Thickbox) that will show all items that match the value entered in the textbox. I am currently using the IFrame implementation of Thickbox. The problem is that the URL to show is hardcoded into the "alt' attribute of the button. What I really need is for the "alt" attribute to pass along the value in the textbox to the popup.
Here is the code so far:
<input type="textbox" id="tb" />
<input alt="Search.aspx?KeepThis=true&TB_iframe=true&height=500&width=700" class="thickbox" title="Search" type="button" value="Search" />
Ideally, I would like to put the textbox value into the Search.aspx url but I can't seem to figure out how to do that. My current alternative is to use jQuery to set the click function of the Search button to call a web service that will set some values in the ASP.NET session. The Search.aspx page will then use the session variables to do the search. However, this is a bit flaky since it seems like there will always be the possibility that the search executes before the session variables are set.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
只需处理按钮的 onclick 即可运行调用 tb_show() 的函数,并传递文本框的值。 就像是
Just handle the onclick of your button to run a function that calls
tb_show()
, passing the value of the text box. Something like如果您阅读手册,在 iframe 内容部分下,它会告诉您参数需要位于 TB_iframe 参数之前。 此后的一切都被剥夺了。
If you read the manual, under the iframe content section, it tells you that your parameters need to go before the TB_iframe parameter. Everything after this gets stripped off.
这是一个想法。 我认为它不是很漂亮,但应该可以工作:
基本上,每次文本框失去焦点时都会更新按钮 alt 标签。 相反,您还可以聆听击键并在每次击键后进行更新。
至于更新查询字符串,我会让您找出最好的方法。 我可以看到在那里放置了一个占位符,例如:&TB=TB_PLACEHOLDER。 然后你就可以进行字符串替换。
Here is an idea. I don't think it is very pretty but should work:
Basically, you update the button alt tag every time the textbox loses focus. Instead, you could also listen to key strokes and update after every one.
As far as updateing the query string, I'll let you figure out the best way. I can see putting a placeholder in there like: &TB=TB_PLACEHOLDER. Then you can just do a string replace.
在 代码隐藏 中,您也可以以编程方式添加 alt 标签,
In the code-behind you could also just add the alt tag progammatically,