Re: [.NET] attribute 的 onclick
<script language="javascript">
function show()
{
<%=pic.ClientID%>.style.display = 'block';
<%=txt.ClientID%>.value = '';
}
</script>
※ 引述《DANGJI (團rz)》之銘言:
: 我想做的是,當textbox偵測到滑鼠的click時
: 呼叫副程式執行:1.清空textbox內的文字
: 2.顯示後面的圖片(讓圖片的visible="true")
: (我看的書裡面,範例只有呼叫javascript彈出對話)
: 我是用attribute的方法
: asp.net網頁開起來沒問題,但是在click那一個textbox的時候,
: ie會顯示錯誤:
: 行:10
: 字元:1
: 錯誤:必需要有物件
: 可以請大大們幫忙看一下是那裡出問題了嗎?
: (有試過用 if txt.Attributes="true" then .... 不過似乎是沒辦法偵測到是不是有
: click)
: <%@ page language="vb" %>
: <script runat="server">
: sub Page_Load(obj as Object, e as EventArgs)
: pic.visible="false" '載入時不顯示圖片
: txt.Attributes.add("onclick","show()")
: end sub
: sub show()
: pic.visible="true" '顯示圖片
: txt.text=""
: end sub
: </script>
: <html>
: <body>
: <form runat="server">
: <asp:image id="pic" imageurl="ok.gif" runat="server" />
: <asp:TextBox id="txt" columns=10 onclick="show()" Text="清除這裡"
: runat="server"/>
: </form>
: </body>
: </html>
--
▃▅▇▆▄ ▆▂▃ `
逝去感情如何能留住,半點癡情遺留殊不易,██▅▇▄▃ ▇▃▂" .
█████████▃i ▁▄▇
更多悽悽慘慘的遭遇…………██▆▃ █▅▆▃ˍ▄*
◢ ▂█▄▇▅▂▌.
我不知道,王~八~蛋~~! ▂▆███ █▄▃ 。fumizuki。Check。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 60.248.175.60
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
Visual_Basic 近期熱門文章
PTT數位生活區 即時熱門文章