在Page_Load的地方加入JavaScript語法

Dim strScript2 As String = ""
strScript2 &= "<script type='text/javascript'> "
strScript2 &= "function show1(){ "
strScript2 &= "var obj=document.getElementById('show_data_1'); "
strScript2 &= "obj.style.display='';"
strScript2 &= "var obj=document.getElementById('show_data_2'); "
strScript2 &= "obj.style.display='none';"
strScript2 &= "} "
strScript2 &= "</script>"
ClientScript.RegisterStartupScript(GetType(String), "show1", strScript2)

Dim strScript3 As String = ""
strScript3 &= "<script type='text/javascript'> "
strScript3 &= "function show2(){ "
strScript3 &= "var obj=document.getElementById('show_data_1'); "
strScript3 &= "obj.style.display='none';"
strScript3 &= "var obj=document.getElementById('show_data_2'); "
strScript3 &= "obj.style.display='';"
strScript3 &= "} "
strScript3 &= "</script>"
ClientScript.RegisterStartupScript(GetType(String), "show2", strScript3)


'onload時載入JavaScript
ClientScript.RegisterStartupScript(GetType(Page), "onload", "<script type='text/javascript'>show1();</script>")

goodlucky 發表在 痞客邦 PIXNET 留言(0) 人氣()