画面刷新问题
两个画面(1.aspx,2.aspx)
1.aspx画面中有400个textbox
现在我在1.aspx中间第100个textbox旁边加一个button,用showdialog弹出2.aspx
在2.aspx中选取值后把值传回1.aspx中的第100个textbox
问题是虽然成功把值获得,但是焦点不在第100个textbox
1.aspx又会重新刷新画面?这是怎么回事?
1.aspx pageload 写
Dim openwinStr As String = " <script> " + vbCrLf
openwinStr += "function openWin() { " + vbCrLf
openwinStr += "var url = '2.aspx ' " + "; " + vbCrLf
openwinStr += "var ret = window.showModalDialog(url); " + vbCrLf
openwinStr += "if (ret != null) { " + vbCrLf
openwinStr += " document.all.TextBox100.value= ret "
openwinStr += "} " + vbCrLf
openwinStr += " </script> " + vbCrLf
Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "clientScript ", openwinStr)
Button1.Attributes.Add( "onclick ", "openWin() ")
2.aspx中 pageload
Dim scriptStr As String = " <script> " + vbCrLf
scriptStr += "function reutrnValue() { " + vbCrLf
scriptStr += " var ret =document.all.TextBox1.value " + vbCrLf
scriptStr += " window.returnValue=ret " + vbCrLf
scriptStr += " window.close() " + vbCrLf
scriptStr += "} " + vbCrLf
scriptStr += " </script> "
我写了js脚本后,虽然焦点设置了,但是1.aspx还是会自动刷新,焦点就没了
是不是我写在pageload的原因?
------解决方案--------------------function openWin() 最后加上return false;
或者你加个html button, 不是服务端的button, 然后加onclick= "openWin(); "