在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>")


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Roger 的頭像
    Roger

    歡迎~ 程式設計 學生 作業 專題製作 程式外包 家教...

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