求助:TextBox改变后点击 Button!希望跳过Button事件,直接刷新到PageLoad

flyin2006 2006-12-18 09:22:18
<asp:TextBox ID="txtDestinationEdition" runat="server" OnTextChanged="txtDestinationEdition_TextChanged" AutoPostBack="True"></asp:TextBox>
<asp:Button ID="btnDestinationSon" Text="选择子项" runat="server" OnClick="btnDestinationSon_Click" />

在TextBox后希望跳过其他的事件,直接让页面跳到到Page_Load事件,有没有可能?给个思路~谢谢!一个困扰一周,才想到这么憋足的解决方法!
...全文
145 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
flyin2006 2006-12-18
  • 打赏
  • 举报
回复
我讲具体些!
举例:TextBox1 TextBox2
效果:当TextBox1值改变时候 TextBox2的值变成TextBox1的值
QQMagicer 2006-12-18
  • 打赏
  • 举报
回复
你的意思是TextChange以后,再次帮定一下数据把?那你把帮定数据拉出来,写成方法,在TextChanged事件中调用一下不就可以了吗?
cpp2017 2006-12-18
  • 打赏
  • 举报
回复
去掉这个Button.
多余的.

在txtDestinationEdition_TextChanged 事件中.稠用重新显示数据的方法就可以
criedshy 2006-12-18
  • 打赏
  • 举报
回复
txtDestinationEdition_TextChanged ()这个事件已经刷新了啊
flyin2006 2006-12-18
  • 打赏
  • 举报
回复
是这样的
在Page_Load里面绑定了数据 显示!(与TextBox内容有关)
txtDestinationEdition_TextChanged ()事件

可能是我不理解:比如TextBox 后面一个不同Button
现在你在TextBox里面输入东西,然后点按钮!是不是执行Page_Load事件,然后执行txtDestinationEdition_TextChanged ()然后btnDestinationSon_Click()我想就是
在txtDestinationEdition_TextChanged ()里面执行完以后然后再次刷新页面显示数据!
而不执行点击事件,不晓得有没有讲明白?
cpp2017 2006-12-18
  • 打赏
  • 举报
回复
txtDestinationEdition_TextChanged ()事件 是服务器事件为什么又加documeng.form1.submit
有点晕了
flyin2006 2006-12-18
  • 打赏
  • 举报
回复
目的是 为了解决一个bug 其实是我程序设计的问题

比如我鼠标从TextBox离开后,然后点击Button
他会执行Page_Load 然后 txtDestinationEdition_TextChanged 然后是btnDestinationSon_Click()
我希望是 执行Page_Load  然后执行txtDestinationEdition_TextChanged
我在txtDestinationEdition_TextChanged ()事件里面加个documeng.form1.submit实现刷新
cpp2017 2006-12-18
  • 打赏
  • 举报
回复
不知道这样做的目的是什么?


在TextBox后希望跳过其他的事件,直接让页面跳到到Page_Load事件
===============
去掉 OnTextChanged="txtDestinationEdition_TextChanged" 就可以
每每听到客户抱怨自己修改和很久的数据由于自己的一个误操作而丢失时,总想让web页面也有像window窗体一样具有提示保存的功能。所以,经过一段时间的研究以后终于实现了这个功能!============ checksave.js =======================<script language="JScript">function window::onbeforeunload(){if (typeof(document.all[‘txtCheckFlag‘]) != "undefined") // to detect whether this page need prompt the save message!{ if (event.clientY<0 && event.clientX>document.body.clientWidth-20 || event.clientY<0 && event.clientX<20 || event.altKey || event.clientY>document.body.clientHeight) event.returnValue="If you have modified some data, you need push the save button to save them. Do you want to save?";}}page need prompt the save message! { // If need document.all["txtCheckFlag"].value=arg; document.forms(0).submit(); return false; }else // If does not need { window.location=arg; return true; }}function showsavemessage(arg){if (window.confirm("Save Change?")) { document.all["txtSave"].value="1"; document.forms(0).submit(); return false; }else { if (arg == ".") { return true; } else { window.location=arg; return false; } }}//-->Page Language="vb" AutoEventWireup="false" Codebehind="test.aspx.vb" Inherits="Test.test" smartNavigation="True" %> test load="pageload()">
loadFiles1DownloadFiles1DownloadFiles1"TestNoNeedCheck.aspx">sohu
loadFiles1DownloadFiles1DownloadFiles1"TestNoNeedCheck.aspx">yahoo
loadFiles1DownloadFiles1DownloadFiles1"TestNoNeedCheck.aspx">MTR textbox id="txtCheckFlag" style="Z-INDEX: 101; LEFT: 213px; POSITION: absolute; TOP: 91px" runat="server">textbox>textbox id="txtSave" style="Z-INDEX: 102; LEFT: 211px; POSITION: absolute; TOP: 139px" runat="server">textbox>button id="LinkButton1" style="Z-INDEX: 103; LEFT: 150px; POSITION: absolute; TOP: 204px" runat="server">LinkButtonbutton> Button id="Button1" style="Z-INDEX: 104; LEFT: 238px; POSITION: absolute; TOP: 271px" runat="server" Text="Button">Button>
======== test.aspx.vb ===============Public Class test Inherits System.Web.UI.Page Protected WithEvents txtSave As System.Web.UI.WebControls.TextBox Protected WithEvents LinkButton1 As System.Web.UI.WebControls.LinkButton Protected WithEvents Button1 As System.Web.UI.WebControls.Button Protected WithEvents txtCheckFlag As System.Web.UI.WebControls.TextBox#Region " Web Form Designer Generated Code " ‘This call is required by the Web Form Designer. Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init ‘CODEGEN: This method call is required by the Web Form Designer ‘Do not modify it using the code editor. InitializeComponent() End Sub#End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ‘Put user code to initialize the page here txtSave.Style.Item("display") = "none" txtCheckFlag.Style.Item("display") = "none" LinkButton1.Attributes("onclick") = "javascript:return checksave(this.href)" ‘ Page.RegisterStartupScript("Prompt", "<script language=""javascript"">function pageload() { } 0 Then Page.RegisterStartupScript("warning", "<script language=""javascript"">function pageload() {if (showsavemessage(‘.‘)) " + Session("URL") + ";}Page.RegisterStartupScript("warning", "<script language=""javascript"">function pageload() {showsavemessage(‘" + Session("URL") + "‘);} 0 Then Session("URL") = Replace(txtCheckFlag.Text, "javascript:", "") Page.RegisterStartupScript("warning", "<script language=""javascript"">function pageload() {" + Session("URL") + ";} 0 Then Session("URL") = Replace(txtCheckFlag.Text, "javascript:", "") Page.RegisterStartupScript("Redirect", "<script language=""javascript"">function pageload() {" + Session("URL") + ";}Page.RegisterStartupScript("Redirect", "<script language=""javascript"">function pageload() {window.location=‘" + Session("URL") + "‘;} 0 Then Page.RegisterStartupScript("TxtSave", "<script language=""javascript"">" + Session("URL") + " 0 Then Session("URL") = Replace(txtCheckFlag.Text, "javascript:", "") Page.RegisterStartupScript("TxtSave", "<script language=""javascript"">function pageload() {" + Session("URL") + ";}Page.RegisterStartupScript("Redirect", "<script language=""javascript"">function pageload() {window.location=‘" + Session("URL") + "‘;}Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton1.Click If Me.ViewState("flag") = True Then Page.RegisterStartupScript("Redict", "<script language=""javascript"">function pageload() {window.location=‘TestNoNeedCheck.aspx‘;}Page.RegisterStartupScript("Redict", "<script language=""javascript"">function pageload() {window.location=‘TestNoNeedCheck.aspx‘;}

62,054

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧